1136:参数数量不正确。预期0 AS3 Flash CS6

时间:2013-04-06 20:19:00

标签: flash flash-cs6 flash-cs5

main.as

package{
    import flash.display.*;
    import flash.events.Event;

    public class main extends MovieClip{

        public function main(){
            changeState(null,"menu");
        }
        public function changeState( CurrentState, NextState){
            if(CurrentState != null){
                removeChild(CurrentState);
            }
            if(NextState == "menu"){
                var mm:mainMenu = new mainMenu(changeState);
                addChild(mm);
            }
            else if(NextState == "game"){
                var g:CollapsingBlocks = new CollapsingBlocks(changeState);
                addChild(g);
            }
            else if(NextState == "exit"){

            }
        }
    }
}

maniMenu.as

package{
    import flash.display.*;
    import flash.events.MouseEvent;
    import flash.events.Event;

    public class mainMenu extends MovieClip{

        var theCallBackFunction:Function;
        public function mainMenu(callBack){
            var btnPlay:mmPlay = new mmPlay();
            btnPlay.addEventListener(MouseEvent.MOUSE_DOWN, btnP_Button);
            btnPlay.x=width/2=btnPlay.width/2;
            btnPlay.y=height/2=btnPlay.height/2;
            addChild(btnPlay);

            var btnExit:mmExit = new mmExit();
            btnExit.addEventListener(MouseEvent.MOUSE_DOWN, btnE_Button);
            btnExit.x=width/2=btnExit.width/2;
            btnExit.y=height/2=btnExit.height/2;
            btnExit.y + btnExit.height + 4;
            addChild(btnExit);

            theCallBackFunction = callBack;
        }
        public function btnP_button(e:MouseEvent){
            theCallBackFunction (this, "game");
            return;
        }
        public function btnE_button(e:MouseEvent){
            theCallBackFunction (this, "exit");
            return;
        }
    }
}

CollapsingBlock.as

..
public function startCollapsingBlocks(callBack) {
..

如何解决这个问题? (错误1136),我正在使用Flash CS6版本。游戏文件名为CollapsingBlocks.fla,主要功能名为startCollapsingBlocks,我试图在这里制作简单的Flash游戏菜单,带2个按钮(播放和退出)。

2 个答案:

答案 0 :(得分:0)

看起来你正在调用一些不需要参数的函数,但是你要给它参数。从您的代码中,它唯一可以是theCallBackFunction (this, "game");theCallBackFunction (this, "exit");,因为这些是唯一的运行时引用

检查theCallBackFunction的值是否总是需要2个参数的函数。

答案 1 :(得分:-2)

0预期参数意味着你在函数括号内添加了一些不是预期的例子:

    function mainMenu(callBack) //this is a 1 argument expected answer
    function mainMenu();        this expects no expected arguments

请检查您要求功能的位置,您会发现函数expatiation / arguments应为0;

否则你已为此函数定义零周长/参数