2013-09-24 111 views
1

我已經創建了四個影片剪輯newGame,說明,關於它們都在menuScreen中。我現在面臨的問題是當我點擊孩子的人會收到以下錯誤Flash AS3上嵌套的影片剪輯

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

回答

1

初始化需要一個事件的說法,因爲它被用作鼠標事件的處理程序。

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

傳說!!!歡呼隊友 – usrNotFound

+0

不用擔心。你能接受答案嗎? – Jono

+2

我做過隊友。歡呼@JonoRR – usrNotFound

0

作爲一個事件監聽器,init()應該有Event類型的參數,或者如果你正在聽的鼠標事件,MouseEvent。所以,寫下如下標題:

function init(e:MouseEvent):void