PDA

View Full Version : dynamic array naming



mojoNYC
April 9th, 2003, 05:14 PM
i'm trying to dynamically name currentArray and return the length, and it keeps returning the wrong value--here's the code:



womenArray = ["","nina.jpg", "tina.jpg", "colleen.jpg"];

_global.currentArray="_root.womenArray";


function aLen(){
hLen=currentArray.length;
trace(hLen);
}
aLen();


it works fine w. the static name in, but this code returns the wrong value--can somebody please help me figure out what's going wrong?
thanks much,
-mojo

Jubba
April 9th, 2003, 05:17 PM
try



function aLen(){
hLen=_root.currentArray.length;
trace(hLen);
}

Jubba
April 9th, 2003, 05:19 PM
nope I was wrong. :)

_global.currentArray = _root.womenArray;

remove the quotes. Having the quotes there made currentArray a string and it didn't copy the array

mojoNYC
April 9th, 2003, 05:48 PM
yes--thankyouverymuch jubba!

i love it when it's something so easy like that...
:P