CS3 Migration Errors

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.

1. 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.

2. 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.

3. 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. 🙂

This entry was posted in Flash. Bookmark the permalink.

10 Responses to CS3 Migration Errors

  1. mybeky says:

    The warning just appear only when the onEnterFrame function isn’t a event listener.
    The code below doesn’t get those errors:
    addEventListener(MouseEvent.CLICK, onEnterFrame);
    function onEnterFrame(event:Event) {
    }

  2. Daniel R. says:

    The display of that warning is controlled by the warn-deprecated-event-handler-error compiler flag. In particular Flex 2 defaulted the flag to false while Flex 3 defaults it to true. If you want to turn it off, the easiest thing to do is modify the flex-config.xml that comes with the SDK.

  3. kp says:

    mybecky, I don’t think that’s true. I don’t get the error at all. even if i’ve assigned no event listener. I’m pretty sure i turned it off somehow in Flash, but can’t seem to find it.

    Daniel R. Cool. But actually I was referring to Flash CS3, which lives (and dies) by its own rules. 🙂

  4. kp says:

    mybeky, maybe you are right. on another install, what you say works. but on my main install, i can’t generate that warning no matter what i do. the following code, alone on frame one of a new fla does not generate a warning.

    function onEnterFrame(event:Event):void
    {
    trace(“hello world”);
    }

  5. Daniel R. says:

    KP: Good point about Flash CS3 versus Flex, that’s what I get for not reading closely enough 🙂 Would be nice if Flash CS3 had similar tweaks for controlling that stuff.

  6. .\Program Files\Adobe\Adobe Flash CS3\en\Configuration\ActionScript 3.0\EnabledWarnings.xml
    you can modify compiler settings in that file.
    see Warnings to aid migrating code from AS2 to AS3

    cheers,
    A.

  7. Vyper says:

    There’s a much easier way than modifying files:

    Simply go to File > Publish Settings
    Go to the ‘Settings’ of the ‘ActionScript version’
    Uncheck ‘Warnings Mode’

    Problem solved.

  8. kp says:

    Vyper, yes, that will do it, but not sure what other warnings that gets rid of. Also, for some reason, I have that selected on my CS3, but still don’t get any warnings.

  9. Nick says:

    What Andras said worked perfectly for me in CS3 – just set kWarning_DepricatedEventHandlerError to false.

  10. Matt L says:

    Ahh this might be a silly request, but could you update the minimalDesigner tool? That was really handy, but it’s a little out of date…
    Then again, I suppose I could do it.

Leave a Reply