-
</hate>
[RESOLVED] [F8] Eval() Question
This should be easy, and may be a stupid question, but bear with me, it's been a long day.
I need to use the eval statement to execute my function properly. My problem is, the statement is correctly evaluated, but I need to execute what it evaluates. Check out my code below.
Code:
changeWallColor = function(newColor){
eval("_root.previewWindow.walls."+newColor+".gotoAndPlay(1);")
/////THE ABOVE NEEDS TO EXECUTE, BUT IS ONLY EVALUATED///////
}
Does that make sense? Currently nothing happens when this function is called, but I need it to make a certain MC play, based on what value is passed into this function. Thanks in advance!
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
</hate>
I'm retarded.
eval("_root.previewWindow.walls."+newColor).gotoAn dPlay(1);
Thanks anyway.
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
Flashmatics
use array notation instead of eval:
PHP Code:
function changeWallColor (newColor){
_root["previewWindow"]["walls"+newColor].gotoAndPlay(1);
}
P.S its better to write functions as
PHP Code:
function a(){
}
rather than
PHP Code:
a = function(){
}
Last edited by silentweed; 11-07-2007 at 08:09 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|