ArgumentError:错误#1063:MethodInfo-152()上的参数计数不匹配。预计1,得到3

时间:2015-02-24 16:21:19

标签: actionscript-3

我很抱歉,但我一直在阅读其他1063错误,我无法将它们应用到我的问题中。我还在AS3工作深度潜水,而且我对其他工作事项感到分心,当我回到它时,我觉得有一个新问题出现了。

我不确定为什么这不起作用,非常感谢一些指导:

 import flash.events.MouseEvent;
stop();

showNextButton(false);

var gift1_var:Number = 0;


var correct_new3:correct_q8     = new correct_q8;
var incorrect_new3:incorrect_q8 = new incorrect_q8;
var incorrect_new4:incorrect_q8 = new incorrect_q8;
var correct_new4:correct_q8     = new correct_q8;

var choices:Array = [
    {
        button: return_btn,
        feedback_mc: correct_new3,
        is_correct: true
    }, 
    {
        button: give_btn,
        feedback_mc: incorrect_new3,
        is_correct: false
    }, 
    {
        button: drink_btn,
        feedback_mc: incorrect_new4,
        is_correct: false
    }, 
    {
        button: donate_btn,
        feedback_mc: correct_new4,
        is_correct: true
    }
];

for (var i:int = 0; i < choices.length; i ++) {

    var choice:Object = choices[i];

    choice.button.addEventListener(MouseEvent.CLICK, onClick);
    choice.button.buttonMode = true;

    choice.button.obj = choice;

}

var num_selected:int = 0;

function onClick (evt:MouseEvent=null):void {
    var btn:MovieClip = MovieClip(evt.currentTarget);
    var choice:Object = btn.obj;
    addChild(choice.feedback_mc);
    choice.feedback_mc.x = btn.x;
    choice.feedback_mc.y = btn.y;
    if (choice.is_correct) {
        gift1_var += 1;
        }
    addToSelected(); 
}

function addToSelected(evt:MouseEvent=null):void {
    num_selected += 1;
    if (num_selected === 2) {
        showNextButton(true);
        showButtons(false);
        //trace("this worked");
    }
}

function showNextButton (is_visible:Boolean):void {
    MovieClip(root).next_mc.visible = is_visible;
}

function showButtons (is_visible:Boolean):void {
    choices.forEach (function (choice:Object):void { 
        choice.button.visible = is_visible;
    });
}

1 个答案:

答案 0 :(得分:1)

哦,我想通了,这是我在forEach

中缺少的另外两个参数

我将 i:int,arr:Array 添加到该位置并且它可以正常工作。很抱歉浪费任何人阅读此内容的时间。

function showButtons (is_visible:Boolean):void {
        choices.forEach (function (choice:Object, i:int, arr:Array):void { 
            choice.button.visible = is_visible;
        });
    }