Flash Actionscript: dynamically named array accessing

was wondering if anyone could help me with this interesting problem:

in this script: (not taken out of context...rewrote to be simplified)

countCurrent = 1;
Info2 = new Array(I, need, help);
FinalVar = ["Info" + countCurrent][0];

trying to dynamically access the array from which the info will be pulled, but when this script runs... the first set of square brackets is all that is returned (FinalVar = "Info1") rather than returning "I" (the data in place 0 in the array)... It would be simple enough to simply name the array to be accessed... but this is running inside of a function that is written to repeat itself for every array (countCurrent is the number) rather than listing them all out, this allows for more arrays to be added or removed from the movie, all accessed within one function (save some time and filesize)

anyone know how (or if) I could perhaps circumlocute this, or just get it to work at all? (my apologies if you couldnt understand the crap I just wrote...lol... can give more info if needed) Much thanks
Isn't it better to use a multi-dimensional array (matrix) in this case? I don't know how they are represented in Flash but it might be something like this:

Info = new Array();
// Preferrably looped:
Info[0] = new Array();
Info[n] = new Array();

Info[0][0] = "Whatever";
after a little playing around... I have discovered the solution to my own problem (how nifty!)

when using any dynamically named object (variable, array, movie clip, etc) Flash needs something to throw it off course...intentionally.

when the array access operators are used, flash returns it without even thinking twice... so to get flash to read the operators as a name, there has to be "_root" before it (or _level0, if _root is being tempermental):

_root["array"+countTotal][0] (note the lack of period between root and the array access operator...)

and with this way, you can name anything heiarchially (is that a word?), so long as the last period is dropped:

_root.newMC.textMC["variable"+countTotal] = 45

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member