View Full Version : Random Movement in Flash MX
dbalatero
April 17th, 2002, 06:05 PM
I took the random motion tutorial, and everything works fine when I export from Flash MX as a Flash 5 file. If I try to export as a Flash 6 file, then the random motion doesn't happen. What's up with this? I'd use Flash 5, but I need some capabilities you can only find in Flash 6 for the project im doing right now.
Any help would be appreciated.
Thanks!
David Balatero
suprabeener
April 17th, 2002, 06:24 PM
the problem is in the methods.
flash 5 used to look through the calling object's namespace by default, so references to local variables and properties could be left withou a prefix. ie _x would refer to the movie that's calling the function's x position.
flash mx doesn't do that (much to my dismay). now the method seems to look at it's own namespace instead, which is usually the prototype chain of whatever object it's an extension of. to get to the calling movie's namespace, use "this".
you need to go through the code and add "this." before every local reference.
there may be other things, but i think that's the big one.
dbalatero
April 17th, 2002, 08:25 PM
Which ones are local references? I'm a good programmer, but new to ActionScript (I've done mostly PHP and Perl), and am still trying to get the rules down pat...
suprabeener
April 18th, 2002, 12:03 PM
i'm using the wrong words. sorry about that. ; )
by local, i meant anything in the methods pertaining to the movie that's calling it:
MovieClip.prototype.move = function(){
var spd = _root.speed; // not pertaining to the calling movie
_x += spd; // this line needs to read: this._x += spd;
}
now that i think about it, local would better describe variables that exist in the function itself, such as "spd" in the above ficticious function.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.