tommy5115
tommy5115

Reputation: 105

AS3 ArgumentError: Error #1063: Expected 0, got 1

Can anyone can help me with this issue. I have no idea with this issue. Just keep getting this issue. Already try modify from this

function init(e:Event = null) to function init() or function init(e:Event)

Appreciated who can help me with this. If no issue on this, it should show food not my stage.

package  {

    import flash.display.MovieClip;
    import flash.ui.Keyboard;
    import flash.events.KeyboardEvent;
    import flash.events.Event;

    public class Main extends MovieClip {

        var snake:Array;
        var score:Number;

        public function Main() {
            // constructor code
            if(stage)
                addEventListener(Event.ADDED_TO_STAGE, init);
            else
                init();
        }

        function init(e:Event = null):void {
            //initialize
            addEventListener(Event.ENTER_FRAME, onEnterFrame);

        }

        function onEnterFrame(e:Event):void {
            var food:Food = new Food();
            this.addChild(food);
            trace("food");
        }
    }

}

Upvotes: 1

Views: 496

Answers (1)

Daniil Subbotin
Daniil Subbotin

Reputation: 6708

Your code is almost correct. Replace if (stage) to if (!stage). If error still happens attach FLA.

Upvotes: 2

Related Questions