dunnjo98
dunnjo98

Reputation: 33

ArgumentError: Error #1063: Argument count mismatch on MethodInfo-152(). Expected 1, got 3

I'm sorry for asking, but I have been reading the other 1063 errors and I am not able to apply them to my issue. I am still working on deep diving in AS3 and I get distracted with other work things, when I get back to it, I feel like a new issue comes up.

I am not sure why this isn't working, would greatly appreciate some guidance:

 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;
    });
}

Upvotes: 1

Views: 357

Answers (1)

dunnjo98
dunnjo98

Reputation: 33

Oh, I figured it out, it is the 2 other arguments I am missing in the forEach

I added i:int, arr:Array into that location and it works. Sorry to waste anyone's time that read through this.

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

Upvotes: 1

Related Questions