"Warning: 1090: migration problem" despite explicit registration of event handlers

I have a game engine class that inherits from MovieClipand handles mouseDown events in a private instance method. For simplicity, I call an event handler onMouseDown. It looks like this:

private function onMouseDown(e:MouseEvent):void
{
    if (_isEnginePlaying)
    {
        _player.attack();
    }
}

I will register it in the class method init(addToStage handler itself), which looks like this:

private function init(e:Event):void
{
    removeEventListener(Event.ADDED_TO_STAGE, init);
    // ...
    stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
    // ...
}

This compiles and works correctly, but the compiler warns:

Warning: 1090: Migration issue: the onMouseDown event handler does not automatically start Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ('mouseDown', callback_handler).

, , , addEventListener(). , ?

+4
1

, , (this). , AS2 , , . , AS3.

, , ( ) .

:

  • onMouseDown. "on-on" AS2, , ; , . Adobe "-Handler" ( 1 2 3), onMouseDown mouseDownHandler:

    private function init(e:Event):void
    {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        // ...
        stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
        // ...
    }
    
    private function mouseDownHandler(e:MouseEvent):void
    {
        if (_isEnginePlaying)
        {
            _player.attack();
        }
    }
    
  • this , this :

    private function init(e:Event):void
    {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        // ...
        addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
        // ...
    }
    

    this, .

  • , , , , . - , , , , , , this, :

    private function stage_onMouseDown(e:MouseEvent):void
    {
        if (_isEnginePlaying)
        {
            _player.attack();
        }
    }
    
  • , , , , , , , , .

+4
source

Source: https://habr.com/ru/post/1681842/


All Articles