[MX] variable as part of a dot address; possible?

What I’m talking about is, is it possible to do something like:

_root.MyVariable.gotoAndPlay(25);

…when MyVariable would happen to be the name of a movieclip sitting in _root?

If it is possible, what would the syntax be? I’ve tried a few things with no luck. :crazy:

use:

_root[MyVariable].gotoAndPlay(25); //no dot in front of the []

the stuff inside the [] counts as one mc. you cannot enter a path inside
like ["_root."+MyVariable].gotoAndPlay(25); <-false
or

eval(MyVariable).gotoAndPlay(25); //there is nothing in front of the eval() otherwise it wouldn’t work
you can use eval too if the whole path is a variable, i.e.:

//mc path to reach is _root.abc.def.ghi
MyVariable=def.ghi
eval("_root.abc."+MyVariable).gotoAndPlay(25);
would work

That did the trick, thanks McGiver.

I used the _root[MyVariable] version, worked like a charm.