1

我已经创建了四个影片剪辑 newGame、instruction、about,它们都在 menuScreen 内。我面临的问题是当我点击其中一个孩子时会出现以下错误

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

我的代码如下

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);
    }
4

2 回答 2

1

init 需要一个事件参数,因为它被用作鼠标事件的处理程序。

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);
    }
于 2013-09-24T11:08:27.123 回答
0

作为事件监听器,init()应该有一个类型的参数,Event或者,如果你正在监听鼠标事件,MouseEvent. 因此,将标题编写如下:

function init(e:MouseEvent):void
于 2013-09-24T11:11:14.120 回答