PDA

View Full Version : [ActionScript 2.0/MX] Trouble with Flash 5 code compatibilty.



blue_chi
July 7th, 2004, 01:48 PM
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.

senocular
July 7th, 2004, 02:13 PM
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)

blue_chi
July 7th, 2004, 02:49 PM
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.

senocular
July 7th, 2004, 02:50 PM
Thanks on the fast reply senocular, but that doesn't explain why it doesnt work in Flash MX either.


yes, it does.

blue_chi
July 7th, 2004, 04:20 PM
It is working! Thanks so much senocular!

senocular
July 7th, 2004, 04:22 PM
welcome :)