【问题标题】:Nested movie clip on Flash AS3Flash AS3 上的嵌套影片剪辑
【发布时间】:2013-09-29 13:39:34
【问题描述】:

我已经创建了四个影片剪辑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);
    }

【问题讨论】:

    标签: actionscript-3 flash


    【解决方案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);
        }
    

    【讨论】:

    • 我确实交配了。干杯@JonoRR
    【解决方案2】:

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

    function init(e:MouseEvent):void
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-29
      • 1970-01-01
      • 2011-08-29
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多