Jump to content
Search Community

ArgumentError: Error #1063: Argument count mismatch..

Benjamin Waller test
Moderator Tag

Recommended Posts

Hello.

 

I want to use TweenLite to display 'ticks & crosses' on stage to represent correct & incorrect click/selection from the user. But I'm not having much luck. I have make some progress.I am using a ButtonSequencer class file, also see attached, to get the correct & incorrect responses for 2 selections with the use of event dispatching. It uses the public getter method called lastClicked to get a reference to the last button that was clicked.. See .AS & .FLA example files attached.

 

On good advice, I have tried isolating the issue in a separate FLA for easier trouble shooting but have only ended up getting an addition issue. See output panel message below.

 

ArgumentError: Error #1063: Argument count mismatch on button_sequence_fla::MainTimeline/removeCross(). Expected 1, got 0.

at Function/http://adobe.com/AS3/2006/builtin::apply()

at com.greensock.core::TweenCore/complete()

at com.greensock::TweenLite/renderTime()

at com.greensock::TimelineLite/forceChildrenToEnd()

at com.greensock::TimelineLite/renderTime()

at com.greensock.core::SimpleTimeline/renderTime()

at com.greensock::TweenLite$/updateAll()

 

What I want to be able to do:

1. Display ticks when correct buttons are clicked in the correct sequence

2. Display crosses when wrong buttons are clicked in the wrong sequence

3. Remove ticks after a short time on stage

4. Remove crosses after a short time on stage

 

Hope someone could give me some pointers..

 

Cheers,

Ben.

Link to comment
Share on other sites

you did not include ButtonSequencer in your zip so the files would not compile.

 

from your error it seems that the problem has to do with the fact that

 

removeCross and removeTick are expecting an event passed in.

you code looks like this:

 

 t.append( new TweenLite(tick_Mc, 1, {autoAlpha:1, onComplete:removeTick}));
function removeTick(event:Event):void{
TweenLite.to(tick_Mc, 2, {autoAlpha:0});

}

 

 

when you use onComplete callbacks in tweens, an event isn't sent to the function.

 

so change removeCross and removeTick to look like this

 

function removeTick():void{
TweenLite.to(tick_Mc, 2, {autoAlpha:0});

}

function removeCross():void {
TweenLite.to(cross_Mc, 2, {autoAlpha:0});
}

Link to comment
Share on other sites

Oh sorry. My mistake. I thought it was included.

 

Thanks. That change fixed up the error message. But I still can't get the crosses and ticks to appear on stage>?

There must be something wrong with the as file.

 

I'm having trouble uploading the .AS file so see a copy of it below.

Cheers

Ben.

package {

import flash.events.*;
import flash.display.InteractiveObject;

public class ButtonSequencer extends EventDispatcher {
	public static const CORRECT:String = "correct";
	public static const INCORRECT:String = "incorrect";

	private var buttonArray:Array;
	private var currentIndex:int = 0;
	private var currentButton:InteractiveObject;

	public function ButtonSequencer(arrayOfButtons:Array) {
		buttonArray = arrayOfButtons;
		for(var i:int = 0; i < buttonArray.length; i++) {
			buttonArray[i].addEventListener(MouseEvent.CLICK, button_onClick);
		}
	}
	private function button_onClick(event:MouseEvent):void {
		//save a reference to the button that was clicked:
		currentButton = InteractiveObject(event.currentTarget);
		if(currentButton == buttonArray[currentIndex]) {
			//the correct button was clicked
			dispatchEvent(new Event(ButtonSequencer.CORRECT));
			currentIndex++;
			if(currentIndex > buttonArray.length - 1) {
				reset();
			}
		} else {
			//the wrong button was clicked
			dispatchEvent(new Event(ButtonSequencer.INCORRECT));
		}
	}
	public function get lastClicked():InteractiveObject {
		return currentButton;
	}
	public function reset():void {
		currentIndex = 0;
	}
	public function set enabled(value:Boolean):void {
		for(var i:int = 0; i < buttonArray.length; i++) {
			if(value == true) {
				buttonArray[i].addEventListener(MouseEvent.CLICK, button_onClick);
			} else {
				buttonArray[i].removeEventListener(MouseEvent.CLICK, button_onClick);
			}
		}
	}
}
}

Link to comment
Share on other sites

no, my mistake. when I opened your file i compiled and the greensock stuff wasn't there so I saved it into a directory with the greensock stuff, but stupid me forgot to think of moving ButtonSequencer.as there. doh.

 

the good news is I think its working the way you want.

 

the 2 main problems.

 

1: you had commented out the activation of the plugins

2: your removeTick and removeCross functions were creating new tweens to make tick and cross invisible... but that was not rewinding the timelines. so even though the mcs appeared invisible the timelines were still completed. telling the timelines to play() again was not doing anything because the "virtual playhead" of those timelines was already at the end.

 

the solution was to make removeTick and removeCross reverse() t and c.

 

here is the code:

 

import flash.events.Event;
import flash.events.MouseEvent;
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.TweenPlugin;
import com.greensock.plugins.AutoAlphaPlugin;
import com.greensock.plugins.VisiblePlugin;

TweenPlugin.activate([AutoAlphaPlugin, VisiblePlugin]);

var buttonArray:Array = [one, two];

var enforcer:ButtonSequencer = new ButtonSequencer(buttonArray);

var t:TimelineLite = new TimelineLite({paused:true});
var c:TimelineLite = new TimelineLite({paused:true});
t.append( new TweenLite(tick_Mc, 1, {autoAlpha:1, onComplete:removeTick}));
c.append( new TweenLite(cross_Mc, 1, {autoAlpha:1,onComplete:removeCross}));

this.cross_Mc.visible = false;
this.tick_Mc.visible = false;


this.cross_Mc.alpha = 0;
this.tick_Mc.alpha=0;

enforcer.addEventListener(ButtonSequencer.CORRECT, correct_onClick);
enforcer.addEventListener(ButtonSequencer.INCORRECT, incorrect_onClick);




function correct_onClick(event:Event):void {
trace("correct");
if(enforcer.lastClicked == one) {
	trace("one clicked");

} else if(enforcer.lastClicked == two) {
	trace("two clicked");

	}
	t.play();

}

function incorrect_onClick(event:Event):void {
trace("sorry, try again");
if(enforcer.lastClicked == one) {
	trace("one clicked");
	;
} else if(enforcer.lastClicked == two) {
	trace("two clicked");

}
c.play();

}

function removeTick():void{
t.reverse();

}

function removeCross():void {
c.reverse();
}

 

just paste all that over the existing code in your fla. should work.

Link to comment
Share on other sites

Fantastic Carl.

works like a dream.Thank you very much.

 

I do have another problem to resole round loading and playing sound files. I posted a comment on your tutorial page http://www.snorkl.tv/2011/07/easy-as3-toggle-and-fade-sound-with-tweenlite-volume-plugin/#more-1127 a few weeks back but since then I've done a little research and I've made some progress so I'll post what I'm up to and where the issues are now.

But maybe I'll post it in a new thread not to confuse this one.

 

Cheers Carl.

Ben.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...