I’m writing this to have a place to point people who write to me about Foundation ActionScript 3.0: Making Things Move!, saying there are errors in the code. The problem comes when you use Flash CS3 to write ActionScript 3.0 and name a function something like onEnterFrame, or onMouseDown. You’ll get an “error” like:
Warning: 1090: Migration Issue: The OnMouseDown event handler is not
triggered automatically by Flash Player at run time in Actionscript 3.0…
First of all, it is not an ERROR. It is a WARNING. It’s telling you that you MIGHT have done something wrong.
In ActionScript 2.0, certain functions were automatically event listeners for certain events. For example to listen for the enterFrame event, all you had to do was write a function named onEnterFrame and it magically executed every frame.
In ActionScript 3.0, this is not the case. You specifically have to add an event listener for every event you want to listen to, and specify a particular function to handle it.
[as]addEventListener(Event.ENTER_FRAME, onEnterFrame);[/as]
If you’ve done that, you are all set. Your onEnterFrame function will execute as planned.
But Flash CS3 thinks you are stupid. Or at least it thinks that you can still use those old functions without adding event listeners. So it warns you. The problem is it warns you even if you have added the event listener. So who’s the stupid one, huh CS3? 😉
So you have three options if you know what you are doing but you are still getting these warnings.
Ignore them. Probably not the best option. You get in the habit of ignoring some warnings and soon you are ignoring other ones, which may be valid.
Name your functions something else. Instead of onEnterFrame, use enterFrameHandler, or onEnterFrameDawg, or whatever. I don’t like this one either. I like onEnterFrame. That’s what I want to use.
Turn off the warnings for these errors. Actually, I don’t know how to do this, but I know I did it and I don’t get these errors any more. But I have strict mode on and warnings mode on in publish settings, and all warnings checked in preferences. I forget what I did to disable those things. If anyone knows, let me know. 🙂