View Full Version : dynamic naming problem
webreake
07-04-2004, 04:39 AM
i have this problem
count++;
_root.attachMovie("b", "b"+count, count);
object = "b"+cont;
trace(object._y) //////////or some property
the trace returns undefined , how can i access this object property??
Wouldnt you want to be tracing the "b"+count, instead of object. Why are you setting object equal to anything?
count++;
_root.attachMovie("b", "b"+count, count);
trace(["b"+count]._y);
To me seems the right way.
CyanBlue
07-04-2004, 05:25 AM
Yeah... I am one of those people who doesn't like the shortcuts... I rather stack a movieClip path in 10 level deep and write as it is than assigning it to the shortcut... :D
Anyways.... You forgot to add the _root in front of the ["b" + count]._y, Cota... ;)
trace(_root["b" + count]._y);
DOH.....Its always the little things I over look. Good catch my man.
ericlin
07-04-2004, 01:43 PM
Other syntax:
count++;
_root.attachMovie("b", "b"+count, count);
obj = _root["b"+count];
trace(obj._y);
or
count++;
obj = _root.attachMovie("b", "b"+count, count);
trace(obj._y);
zimady
07-05-2004, 07:23 AM
I've never seen that way of resolving dynamicly created movie clips. If it's of interest, the method I usually use is...
count++;
_root.attachMovie("b", "b"+count, count);
obj = eval ( "_root.b" + count );
trace(obj._y);
webreake
07-06-2004, 02:47 AM
thank you everyone
i almost lost my hair
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.