[ActionScript 2.0/MX] Trouble with Flash 5 code compatibilty

Hello people, I read a tutorial here ages back (I can’t find it now) Anyway, it was about something different but I got this code from it and it works only when the SWF is exported in Flash 5 version.

onClipEvent (enterFrame) {
	new_dest = _xmouse+_x;
	pos = _x;
	vel = ((dest-.1*pos)/9+vel*0.9);
	_x += vel;
	dest = new_dest-_x;
}

Where does the compatibilty problem lay? and How can we make it work on Flash MX or MX 2004?

Thanks in advance.

the problem is vel. Its used before its defined.
http://www.kirupa.com/developer/oop2/AS2OOPChangedAndAdded2.htm (#2)
you’ll just need to give it a default value in an onClipEvent(load) - something like 0. (Seems you need to with dest too)

Thanks on the fast reply senocular, but that doesn’t explain why it doesnt work in Flash MX either…

I will try defining the codes and then I will come back to you. Thanks.

yes, it does.

It is working! Thanks so much senocular!

welcome :slight_smile: