1
votes

I have created four movie clip newGame, instruction, about and they all are inside menuScreen. The problem i am facing is while i click one of child will get the following error

ArgumentError: Error #1063: Argument count mismatch on hangMan_fla::MainTimeline/init(). Expected 0, got 1.

my code is as follows

function startGame() :void {

        stage.addChild(menuScreen);
        menuScreen.mouseEnabled = false;
        //menuScreen.mouseChildren = false;
        menuScreen.x = 278;
        menuScreen.y = 168;
        this.menuScreen.removeEventListener(MouseEvent.MOUSE_UP,init);

        this.menuScreen.newGame.addEventListener(MouseEvent.MOUSE_UP,this.init);
        this.menuScreen.instruction.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.init);
        this.menuScreen.about.addEventListener(MouseEvent.MOUSE_UP, this.init);

}

function init():void
    {
        trace("this is working");
        tween = new fl.transitions.Tween(menuScreen, "y", fl.transitions.easing.Strong.easeOut, menuScreen.y, (-this.menuScreen.height) / 2, 0.8, true);
    }
2

2 Answers

1
votes

init needs an event argument because it's being used as a handler for a mouse event.

function init(event:MouseEvent):void
    {
        trace("this is working");
        tween = new fl.transitions.Tween(menuScreen, "y", fl.transitions.easing.Strong.easeOut, menuScreen.y, (-this.menuScreen.height) / 2, 0.8, true);
    }
0
votes

As an event listener, init() should have a parameter of type Event or, if you are listening for mouse events, MouseEvent. So, write the header as follows:

function init(e:MouseEvent):void