1
votes

Since I moved to using adobe flash 2017+, I've gotten warnings 1082/1083. The warning is: Warning: 1082: Migration issue: Method gameThread will behave differently in ActionScript 3.0 due to the change in scoping for the this keyword. See the entry for warning 1083 for additional information.

Although the only error which I am getting is for putting events inside classes, I cannot add mouse events or any events without having these warnings and I don't know how to fix...
People suggested to remove super() which is not the solution.

Example of event which I added to main code error comes on line " addEventListener...."

package  {

    import flash.display.MovieClip;
    import flash.events.Event;
    import data.Player;


    public class Game extends MovieClip {

        private var players:Array = new Array();

        public function Game() {
            super();

            resetPlayers();
            addEventListener(Event.ENTER_FRAME, this.gameThread);
        }

        private function resetPlayers():void{
            for (var i:int = 0; i < this.numChildren; i++){
                if (getChildAt(i) is Player){
                    players.push(getChildAt(i));
                }
            }
        }

        protected function gameThread(event:Event):void{
            for (var i:int = 0; i < this.players.length; i++){
                players[i].fall();
            }
        }
    }
}
1
@KevinWang, please also format code when you make edits. Your phrasing changes look helpful, but the question still looks sloppy with "package {" outside the code box. - Brian

1 Answers

0
votes

You are be able to overcome this issue by simply removing the this keyword. It's not needed in this case.

addEventListener(Event.ENTER_FRAME, gameThread);

In AS3 methods are exectued in the context (your Game class) it's defined. Same for the other uses of the this keyword. players is a class variable of Game, resetPlayers() and gameThread() are methods of Game -> so it's all in the same context.