Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3中的参数错误1063_Actionscript 3_Flash Cs6_Argument Error - Fatal编程技术网

Actionscript 3 AS3中的参数错误1063

Actionscript 3 AS3中的参数错误1063,actionscript-3,flash-cs6,argument-error,Actionscript 3,Flash Cs6,Argument Error,所以我一直在做一个叫做石头剪刀布蜥蜴斯波克的游戏 我得到了这个错误: ArgumentError:Error#1063:FlashGame_fla::MainTimeline/BackTobana()上的参数计数不匹配。预期为0,得到1 这是我的主要代码: import flash.display.MovieClip; import flash.events.MouseEvent; import flash.text.TextFormat; rulesButton.addEventListen

所以我一直在做一个叫做石头剪刀布蜥蜴斯波克的游戏

我得到了这个错误: ArgumentError:Error#1063:FlashGame_fla::MainTimeline/BackTobana()上的参数计数不匹配。预期为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");
}
因此错误出现在函数backtobana()中,我似乎无法修复它。
有人能帮我吗?非常感谢。

MouseEvent侦听器的回调函数将被传递一个
MouseEvent
。改变

function backtoBanana():void

与其他回调函数一样:

function Click_backtoMain(event:MouseEvent):void

哦,哇。我想这就是我缺乏连贯性的原因。非常感谢你的帮助,每个人都会这样。别忘了接受我的回答:)我可以看到有人向你指出了这一点,如果你能仔细检查你所有的老问题并接受那些对你有帮助的答案,我将不胜感激。哈哈,我刚刚做到了:)因为在此之前,我的声誉太低,无法立即接受答案。再次感谢!:)顺便提一下,我还有一个关于类型错误的actionscript问题:不知您是否可以再次提供帮助?:)谢谢好的,我去看看!:)
function Click_backtoMain(event:MouseEvent):void