Actionscript : Bahhh
- Started
- Last post
- 6 Responses
- tobor
say i have a movie called 'photo10'. And i want to play the second frame of 'photo10'.
i = 10;
_root.eval("photo"+i).gotoAndPla...
does this even make sense?
- versa0
do you have any other photo Holder MCs other than photo10?... cause if not, you might be doing more work than necessary by sending a var into an eval...........if you do have more than one, than something close could be worked pretty easily..
and if you use eval this way, just put the "_root" part of the path inside the eval paranthesis as wellna mean
- tobor0
_root["photo"+i].got
oAndPlay(2);works too.
What do the square brackets stand for?
- ganon0
[] is array access....
- jkosoy0
or you could do it the long complicated way like i do. :)
var i = 10;
var which_mc= eval("_root.photo" + i);
which_mc.gotoAndPlay(2);
- shant0
you just had one thing wrong:
i = 10;
eval("_root.photo"+i).got
oAndPlay(2);
- SmilingBuddh0
The array method is definitely the way to go. It's cleaner and faster.
You can refer to a second MC in the scope of a first MC like this:
mc1["mc2"]
This works because flash 'stores' all of the MCs in a given file in a set of nested arrays. These arrays are associative, so youc an access any item in the array using it's instance name.
You can take this further:
mc1["mc2"]["mc3"]
mc1["mc2"]["mc3"]["mc4"]It's really fast. The other way (using eval) is outdated and way too complicated. So do it this way.