Flash AS3上的嵌套影片剪辑

时间:2013-09-24 11:06:48

标签: actionscript-3 flash

我创建了四个影片剪辑newGame,指令,关于它们都在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);
    }

2 个答案:

答案 0 :(得分: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);
    }

答案 1 :(得分:0)

作为事件监听器,init()应该具有Event类型的参数,或者,如果您正在侦听鼠标事件,则MouseEvent。因此,按如下方式编写标题:

function init(e:MouseEvent):void