2013-10-23 10 views
0

그래서 나는 바위 가위라고 불리는 게임에서 일 해왔다.AS3에서의 인수 오류 1063

이 오류가 발생했습니다. ArgumentError : 오류 # 1063 : FlashGame_fla :: MainTimeline/backtoBanana()에서 인수 개수가 일치하지 않습니다. 0 예상 1.

이 내 주요 코드 가지고 :

import flash.display.MovieClip; 
import flash.events.MouseEvent; 
import flash.text.TextFormat; 

rulesButton.addEventListener(MouseEvent.CLICK, toggleRule); 
gameRules.addEventListener(MouseEvent.CLICK, toggleRule); 
gameRules.visible = false; 
gameRules.buttonMode = true; 

function toggleRule(evt:MouseEvent):void 
{ 
    gameRules.visible = ! gameRules.visible; 
} 

menuButton.addEventListener(MouseEvent.CLICK, Click_backtoMain); 

function Click_backtoMain(event:MouseEvent):void 
{ 
    gotoAndStop(213); 
} 

var isRolling:Boolean = false; //defalt is "false" 
var pDieVal:int = 0; 
var gDieVal:int = 0;  
var pScore:int = 0; 
var gScore:int = 0; 
var pRolls:int = 0; 

pDieMC.stop(); 
gDieMC.stop(); 
msgDisplay.text = "Click on the banana \nbutton to roll the die!"; 
pScoreDisplay.text = "0"; 
gScoreDisplay.text = "0"; 

rollButton.addEventListener(MouseEvent.CLICK, rollDie); 
rollButton.addEventListener(MouseEvent.CLICK, dieRoll); 

bananaWinLose.visible = false; 
gameOverBananaMC.visible = false; 
toMenuBtn.visible = false; 
rollAgainBtn.visible = false; 

function rollDie(evt:MouseEvent): void 
{ 
    if (isRolling) 
    { 
     //change flag to show die is NOT rolling 
     isRolling = false; 
     //change the label on the button to "BANANA!" 
     buttonDisplay.text = "BANANA!"; 
     // STOP the dice animations 
     pDieVal= Math.ceil(Math.random() * pDieMC.totalFrames); 
     pDieMC.gotoAndStop(pDieVal); 
     gDieVal = Math.ceil(Math.random() * gDieMC.totalFrames); 
     gDieMC.gotoAndStop(gDieVal); 
     //set message display to an empty string 
     msgDisplay.text = ""; 
     whoWon(); 
     score(); 
    } 
    else 
    { 
     //change flag to show die is rolling 
     isRolling = true; 
     //change the label on the button to "Stop" 
     buttonDisplay.text = "POPADAM!"; 
     //PLAY the dice animations 
     pDieMC.play(); 
     gDieMC.play(); 
     //clear the message display 
     msgDisplay.text = ""; 
    } 
} 

function whoWon():void 
{ 
    // is it a tie? 
    if (pDieVal == gDieVal) 
    { 
     msgDisplay.text = "Papoi?! It's a tie!"; 
    } 
    else 
    { 
     // assume the player has lost 
     var hasPlayerWon:Boolean = false; 
     // determine if the player wins 
     if (pDieVal == 1 && (gDieVal == 4 || gDieVal == 5)) 
     { 
      hasPlayerWon = true; 
     } 
     else if (pDieVal == 2 && (gDieVal == 1 || gDieVal == 5)) 
     { 
      hasPlayerWon = true; 
     } 
     else if (pDieVal == 3 && (gDieVal == 1 || gDieVal == 2)) 
     { 
      hasPlayerWon = true; 
     } 
     else if (pDieVal == 4 && (gDieVal == 3 || gDieVal == 2)) 
     { 
      hasPlayerWon = true; 
     } 
     else if (pDieVal == 5 && (gDieVal == 3 || gDieVal == 4)) 
     { 
      hasPlayerWon = true; 
     } 
     // display the results to the player 
     if (hasPlayerWon) 
     { 
      msgDisplay.text = "Yay! You win!"; 
     } 
     else 
     { 
      msgDisplay.text = "Boo! Stuart wins!"; 
     } 
    } 
} 

function dieRoll(evt:MouseEvent):void 
{ 
    trace("calculating pRolls"); 
    if (pRolls == 20) 
    { 
     rpslsWon(); 
    } 
    else 
    { 
     //increment pRolls by 1 
     pRolls++; 
    } 
} 

function score():void 
{ 
    //if player wins, his/her score increases by 1 
    if (msgDisplay.text == "Yay! You win!") 
    { 
     pScore = pScore + 1 
     pScoreDisplay.text = pScore.toString(); 
    //if player loses, computer score increases by 1 
    } 
    else if (msgDisplay.text == "Boo! Stuart wins!") 
    { 
     gScore = gScore + 1 
     gScoreDisplay.text = gScore.toString(); 
    //if neither wins, their scores remain unchange 
    } 
    else 
    { 
     pScore = pScore 
     gScore = gScore 
    } 
} 

function rpslsWon():void 
{ 
    gameOverBananaMC.visible = true; 
    bananaWinLose.visible = true; 
    bananaWinLose.text = "Kampai! You are totally bananas!! \nYour Score: " + pScore; 
    toMenuBtn.visible = true; 
    rollAgainBtn.visible = true; 
    toMenuBtn.addEventListener(MouseEvent.CLICK, Click_backtoMain); 
    rollAgainBtn.addEventListener(MouseEvent.CLICK, backtoBanana); 
} 

function backtoBanana():void 
{ 
    pScore = 0; 
    gotoAndStop("menu"); 
    gotoAndStop("banana"); 
} 

그래서 오류가 함수 backtoBanana(), 나는 그것을 고칠 수없는 것 나타납니다. 누군가 나를 도울 수 있습니까? 고마워.

답변

1

MouseEvent-listener의 콜백 함수는 MouseEvent으로 전달됩니다.

function backtoBanana():void 

단지 다른 콜백 함수와 같은

function backtoBanana(event:MouseEvent):void 

에 변경 :

function Click_backtoMain(event:MouseEvent):void 
+0

을 오 와우. 내 일관성이 부족한 것 같아. 도와 줘서 고마워. –

+0

모두에게 일어난 일. 내 대답을 수락하는 것을 잊지 마세요 :) 누군가가 당신에게 이것을 지적했다는 것을 알 수 있습니다. 당신이 낡은 질문을 모두 거쳐 당신을 도운 대답을 받아들이면 크게 감사 할 것입니다. – ebbs

+0

하하 그냥 완료 :) 전에 사촌, 내 명성은 즉시 대답을 받아 들일 너무 낮습니다. 다시 한 번 감사드립니다! :) 내가 형식 오류에 대한 또 다른 actionscript 질문이있는 방식으로 : http://stackoverflow.com/questions/19547219/typeerror-error-1009-in-as3-flash-cs6 당신이 다시 도울 수 있다면 궁금해? :) –