PDA

View Full Version : Help: I can build the string but not access the variable


CarlBanks
01-08-2002, 10:20 AM
Someone please put me out of my misery!
I have tried just about everything I can think of but it just won't work for me. (Flash 5.0)

On _level0 I have global variables which I am using as prerequisites:

B1_0 = "A" ;
B1_1 = 2 ;
B7_0 = "C";
B7_1 = 3;
.....etc.....

I need to access this data from another level dynamically.
variable z is a string (e.g. B1) assigned this value depending on the input from the movie user.

If I write

prereq = _level0.B1_0;

then prereq is given the value "A" (which is what I want).
However, when I try to make this happen dynamically with an expression:

prereq = "_level0."+z+"_0";
or prereq = ["_level0."+z+"_0"];

it doesn't work and gives me the string: "_level0.B1_0"

How do I get the value of the variable instead of getting the string?

Billy T
01-08-2002, 10:39 AM
ok firstly I think this is in the wrong forum

have you tried

_level0[z+"_0"]

??

also where is z being set?

Ricod
01-08-2002, 10:40 AM
var preprereq = z+"_0";
prereq = _level0[this.preprereq];

Now, if u declare z=B1; it oughta work.

ah, man ! The T beat me to it !