|
-
Working with a dynamic instance
I am trying to move a movie clip across the stage. This clip has the instance name "runningGirl". I want to affect this movie clip dynamically. That way, when I add "runningBoy" into the mix, I can use the same function, but pass along the different intance name.
Right now, this is how I'm doing it.
I am calling a function in an if statement:
Code:
if(*parameters*){
ThrowIowan(runningGirl);
}
Then, the actual global function looks like this:
Code:
_global.ThrowIowan = function(iowan){
trace("Big D & the Kid's Table");
dx = 86-_root.iowan._x;
dy = _root.iowan._y-222;
_root.iowan._x += dx;
_root.iowan._y -= dy;
}
It's not working though, because I think it's not reading the instance name right (_root.iowan._x ). I don't think the variable is being passed correctly. How can I make this work?
Note: The function is being called successfully, because the trace shows up.
-
Since you're passing a string instead of a variable, you need to put quotes around "runningGirl," otherwise it will think you're trying to pass whatever is inside the runningGirl variable, which is, presumably, undefined.
Additionally, you need to eval your passed variable so that flash can convert the value of "iowan" to the appropriate instance name. You can do this thusly:
-
Thanks, Rancor, I appreciate the help. That worked!
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
|