PDA

View Full Version : Passing a movieClip address as a variable


baritone87
06-07-2004, 07:50 PM
Is it possible to pass a movieClip address as a variable to use in a function?

Passing just the name works:

genericAction = function(passedMC){
_root[passedMC].play();
}
genericAction("check_mc");


But, if I try to pass the ADDRESS it doesn't work:

genericAction = function(passedMC){
passedMC.play();
}
genericAction("_root.main_mc.check_mc");


How can I accomplish this functionality?
Thanks in advance for any help
B

petefs
06-07-2004, 07:53 PM
what you're telling it in the second example, essentially, is

_root["_root.main_mc.check_mc"].play();
which evals to
_root._root.main_mc.check_mc which is an invalid target

I suggest you use:

genericAction = function ( passedMC )
{
passedMC.play();
}

then:

genericAction(_root.main_mc.check_mc);

baritone87
06-07-2004, 11:08 PM
Thanks a million petefs,
That was the problem.

You rock,
B

petefs
06-07-2004, 11:34 PM
If only it were that easy to rock... ^_^

You're welcome, all the same! Hope your project turns out great ^_^