Forum Topic: [ AS2 ] Variable within a variable

(204 views • 12 replies)

This topic is 1 page long.

<< < > >>
None

Denegoth

Reply To Post Reply & Quote

Posted at: 11/5/09 02:28 PM

Denegoth NEUTRAL LEVEL 07

Sign-Up: 12/17/06

Posts: 94

Is there a way I can store a variable within another?

For example I'd like to store Variable1 in Variable2, so when I change the value of Variable2, Variable1 also changes.

Thanks in advance.


None

Super-Yombario

Reply To Post Reply & Quote

Posted at: 11/5/09 02:43 PM

Super-Yombario FAB LEVEL 06

Sign-Up: 03/16/07

Posts: 1,180

It's called an array.

var array:Array = new Array ( 'lol', 'lol2', 'lol3' );
// array[0] is lol, array[1] is 'lol2', and array[2] is 'lol3'
//Or the lazy way to write it, which is still acceptable:
array = new Array ('lol','lol2','lol3');
/// Even lazier, but more work:
array[0]='lol';
array[1]='lol2';
array[2]='lol3';
// And dimensional arrays:
var array:Array = [
['lol', 'lol', 'lol' ],
['lol', 'lol', 'lol' ],
['lol', 'lol', 'lol' ]
];
// array[0][0] is 'lol', array[0][1] is lol, array [0][2] is lol
// array[1][0] is 'lol', array[1][1] is lol, array [1][2] is lol
// array[2][0] is 'lol', array[2][1] is lol, array [2][2] is lol

RIP Ed McMahon - RIP Farrah Fawcett - RIP Michael Jackson
But wait, there's more...
RIP Billy Mays


None

grafik2d

Reply To Post Reply & Quote

Posted at: 11/5/09 02:58 PM

grafik2d NEUTRAL LEVEL 10

Sign-Up: 06/29/04

Posts: 182

you can also write like this

FatLevel=10
ExerciseLevel=50

Health=0-FatLevel+ExerciseLevel

this way whenever the Fat level or Exercise level changes Health is also changed


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 11/5/09 03:02 PM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,606

If their both gonna have the same value, whats the point of having 2?

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

Rustygames

Reply To Post Reply & Quote

Posted at: 11/5/09 03:04 PM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,661

I think what he's talking about is a pointer.

In flash anytime you assign something it just stores a reference (or pointer) to that variable. Everything does this by default except for primitive data types (IE: String, Number etc). If you wanted to create a pointer to a number I'm afraid you're out of luck. You'll have to come up with some sort of workaround

- Matt, Rustyarcade.com


None

Denegoth

Reply To Post Reply & Quote

Posted at: 11/5/09 03:14 PM

Denegoth NEUTRAL LEVEL 07

Sign-Up: 12/17/06

Posts: 94

This is what I want precisely:
First, frame 1 on the timeline sets box1l to 1, to represent there will be one item inside box 1. Whenever you open the box, it will set lootamount to the variable box1l. Once you take the item out of the box, it will subtract 1 from lootamount.

The reason I want to overcomplicate this is so I can use a single movie clip for every interior of a box without making an insane amount of code.


None

Rustygames

Reply To Post Reply & Quote

Posted at: 11/5/09 03:15 PM

Rustygames LIGHT LEVEL 18

Sign-Up: 05/07/05

Posts: 6,661

Gotya, I have the perfect explanation:

Close flash; you're too stupid to use it

- Matt, Rustyarcade.com


None

Denegoth

Reply To Post Reply & Quote

Posted at: 11/5/09 03:19 PM

Denegoth NEUTRAL LEVEL 07

Sign-Up: 12/17/06

Posts: 94

At 11/5/09 03:15 PM, Rustygames wrote: Gotya, I have the perfect explanation:

Close flash; you're too stupid to use it

Thanks for your contribution.


None

Denegoth

Reply To Post Reply & Quote

Posted at: 11/5/09 03:23 PM

Denegoth NEUTRAL LEVEL 07

Sign-Up: 12/17/06

Posts: 94

At 11/5/09 03:14 PM, Denegoth wrote: This is what I want precisely:
First, frame 1 on the timeline sets box1l to 1, to represent there will be one item inside box 1. Whenever you open the box, it will set lootamount to the variable box1l. Once you take the item out of the box, it will subtract 1 from lootamount.

Fuck, realised I forgot to add this:

it will subtract 1 from lootamount, thus also subtracting 1 from box1l. The box will not execute the rest of the code if lootamount is 0. I have all of the code done except for what I'm asking about.


Expressionless

Archon68

Reply To Post Reply & Quote

Posted at: 11/5/09 07:27 PM

Archon68 LIGHT LEVEL 22

Sign-Up: 09/09/07

Posts: 3,478

At 11/5/09 03:15 PM, Rustygames wrote: Close flash; you're too stupid to use it

In other words... uhh...

Wait, he summed it up perfectly.

I code in AS2, in case I forgot to mention it.

BBS Signature

None

Denegoth

Reply To Post Reply & Quote

Posted at: 11/5/09 08:22 PM

Denegoth NEUTRAL LEVEL 07

Sign-Up: 12/17/06

Posts: 94

At 11/5/09 07:27 PM, Archon68 wrote:
At 11/5/09 03:15 PM, Rustygames wrote: Close flash; you're too stupid to use it
In other words... uhh...

Wait, he summed it up perfectly.

Hurr Durr

Whoever would've guessed. Posting a thread asking for some help and getting elitist dicks. Please contribute something other than your gargantuan ego.

I worked it out anyway.


None

Super-Yombario

Reply To Post Reply & Quote

Posted at: 11/6/09 12:25 PM

Super-Yombario FAB LEVEL 06

Sign-Up: 03/16/07

Posts: 1,180

They're no elitists but they're not exactly having the right attitude.

RIP Ed McMahon - RIP Farrah Fawcett - RIP Michael Jackson
But wait, there's more...
RIP Billy Mays


None

grafik2d

Reply To Post Reply & Quote

Posted at: 11/7/09 09:30 AM

grafik2d NEUTRAL LEVEL 10

Sign-Up: 06/29/04

Posts: 182

At 11/6/09 12:25 PM, Super-Yombario wrote: They're no elitists but they're not exactly having the right attitude.

Yeah, I agree somewhat, but what else can you do when the explanation is that mess up and I doubt what he wants to do is really that complicated.


All times are Eastern Standard Time (GMT -5) | Current Time: 06:33 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!