View Full Version : passing var to movie control command?
sozugk
June 8th, 2003, 07:02 PM
Hi,
I have question that I believe should be simple. Here it is;
instead of writing for example;
test.gotoAndPlay(2);
I wrote this but does not seem to work;
x = "test";
x.gotoAndPlay(2);
Is there a format that I should use to get this to work? Thanks.
Raydred
June 8th, 2003, 07:31 PM
try this...
dont know if it'll work but what the hey..
x = eval("_root.test");
x.gotoandPlay(2);
i know this works when doing dynamic stuff:
for(i=0;i<5;i++){
_root["movieclip" + i].play();
}
hmm =)
sozugk
June 8th, 2003, 07:33 PM
works!! thx... what does eval do anyways?
Raydred
June 8th, 2003, 07:35 PM
eval( ) works when you want to evaluate something as litteral.. such as a variable name etc..
since you were doing
x = "test"; it was assigning it as a string.
if you do the eval("test") it goes, ok, this must be a variable name or an object or something other than a string =)
its intended for dyanamic thigns , its most handy =)
ahmed
June 8th, 2003, 07:37 PM
the eval way is deprecated in MX, so you might just wanna stick with the 2nd method :):
x = "test"
_root[x].gotoAndPlay(2);
Raydred
June 8th, 2003, 07:38 PM
or do what ahmed said.. =)
even though eval() is still king in other languages.. =)
sozugk
June 8th, 2003, 07:40 PM
nice! thanks for the help Raydred and ahmed :)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.