Four successive actions from one button

I am attempting to fire successive actions from the same button by setting different variables throughout the process like so…

(using Fuse to animate)

var spotOne:Boolean = true;
var spotTwo:Boolean = false;
var spotThree:Boolean = false;
var spotFour:Boolean = false;

btn.onRelease = function() {
if (spotOne = true) {
ball.slideTo(450, 100, 1);
spotOne = false;
spotTwo = true;
} else if (spotTwo = true) {
ball.slideTo(450, 150, .5);
spotTwo = false;
spotThree = true;
} else if (spotThree = true) {
ball.slideTo(100, 150, 1);
spotThree = false;
spotFour = true;
} else {
ball.slideTo(100, 100, 1);
spotFour = false;
spotOne = true;
}
};

This isn’t working for me. Can anyone tell me what I’m doing wrong? TIA.

Wrong: if (spotOne = true)
Right: if (spotOne == true)
Better: if (spotOne)

I had that thought but I’m not so familiar. Can you show me? TIA.

[quote=glosrfc;2357260]Wrong: if (spotOne = true)
Right: if (spotOne == true)
Better: if (spotOne)[/quote]

Thanks glosrfc

There’s an example in the Flash help files…or do a search in Google for “actionscript switch” for the same example.
There’s a simpler explaination here too http://www.kirupa.com/developer/actionscript/switchcase.htm

Thanks again glosrfc. I do understand the ways of the switch in general. I’m just not sure how to execute it in the context of this function.

Here’s my somewhat incomplete stab at it. Any help is greatly appreciated.

var spotOne:Boolean = true;
var spotTwo:Boolean = false;
var spotThree:Boolean = false;
var spotFour:Boolean = false;

btn.onRelease = function() {
var location:Number = ?

switch(location) {
case spotOne:
ball.slideTo(450, 100, 1);
spotOne = false;
spotTwo = true;
break;
case spotTwo:
ball.slideTo(450, 150, .5);
spotTwo = false;
spotThree = true;
break;
case spotThree:
ball.slideTo(100, 150, 1);
spotThree = false;
spotFour = true;
break;
case spotFour:
ball.slideTo(100, 100, 1);
spotFour = false;
spotOne = true;
break;
}

You won’t have a lot of luck using boolean values in a long case/switch statement because, by their nature, they only return two possibilities - true or false - and things can get messy quickly. Try this:

var button_var = 1;
btn.onRelease = function() {
	switch (button_var) {
	case 1 :
		trace("Current button value = " + button_var);
		button_var = 2;
		trace("New button value = " + button_var);
		// actions here
		break;
	case 2 :
		trace("Current button value = " + button_var);
		button_var = 3;
		trace("New button value = " + button_var);
		// actions here
		break;
	case 3 :
		trace("Current button value = " + button_var);
		button_var = 4;
		trace("New button value = " + button_var);
		// actions here
		break;
	case 4 :
		trace("Current button value = " + button_var);
		button_var = 1;
		trace("New button value = " + button_var);
		// actions here
		break;
	}
};

Excellent! Thank you so much.