ArgumentError:错误#1063:MethodInfo-152()中的参数计数不匹配。预计1,得到3
问题描述:
我很抱歉提问,但我一直在阅读其他1063错误,我无法将它们应用于我的问题。我仍然在AS3上进行深度潜水,当我回到它时,我感到分心了其他工作,我觉得像是出现了一个新问题。ArgumentError:错误#1063:MethodInfo-152()中的参数计数不匹配。预计1,得到3
我不知道为什么,这是行不通的,将不胜感激一些指导:
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;
});
}
答
哦,我想通了,这是我在foreach缺少2个其他参数
我加入了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;
});
}
我不相信错误是在你显示的代码中,因为我看不到任何你调用3个参数的方法。你是从Flash IDE运行的吗?如果是这样,如果你去设置并检查'允许调试'选项,你应该能够得到错误的行号。 – 2015-02-24 16:55:30