简体   繁体   English

Flash AS3上的嵌套影片剪辑

[英]Nested movie clip on Flash AS3

I have created four movie clip newGame, instruction, about and they all are inside menuScreen. 我已经创建了四个影片剪辑newGame,instruction和about,它们都位于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);
    }

init needs an event argument because it's being used as a handler for a mouse event. 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);
    }

As an event listener, init() should have a parameter of type Event or, if you are listening for mouse events, MouseEvent . 作为事件侦听器, init()应该具有Event类型的参数,或者,如果您正在侦听鼠标事件,则应具有MouseEvent类型的参数。 So, write the header as follows: 因此,将标头编写如下:

function init(e:MouseEvent):void

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM