Set Transform Color Issue

Hey, I am trying to do this:

Inside a movie clip this what should be happening

When a user rolls over MC mc should turn green

When user roll out if green go back to original color = black

When user clicks MC turn red

If MC is red When user rolls back onto MC stay red and NOT turn green

But when MC is red and clicked again, MC goes back to green

here’s what I got so far:

(inside the MC)


colorObj = new Color(this);
colorObj.setTransform({ra:100, rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0});
state = 0;
this.onRollOver = function() {
	colorObj.setTransform({ra:100, rb:0,ga:100,gb:45,ba:100,bb:0,aa:100,ab:0});
	if (state != 0){
		colorObj.setTransform({ra:100, rb:69,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0});
	}
	//trace(state);
}
this.onRollOut = function() {
	if (state == 0) {
	colorObj.setTransform({ra:100, rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0});
	}
}
this.onPress = function() {
	state = 1;
	colorObj.setTransform({ra:100, rb:69,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0});
	if(colorObj = ({ra:100, rb:69,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0})){
	//trace("Turn green");

	}
}

couldnt you just do it with different frames in the movie rather than the color Object? Unless that it what you want to use.

i think that would be real confusing that way.
let me show you whats going on

[AS]
this.onRollOver = function() {
if(clicked == false}{
colorObj.setTransform(green);
}
}

this.onRollOut = function(){
if(clicked == false){
colorObj.setTransform(black);
}
}

this.onPress = function(){
if(clicked == false){
clicked = true;
colorObj.setTransform(red);
}
else{
clicked = false;
colorObj.setTransform(green);
}
}
[/AS]

this is with as. Change the string colors to your setTransform values. This will reset to as if it had never been clicked if you click twice, dunno if thats what you want.

You can use getRGB() and setRGB(), much shorter :wink:

[AS]colorObj = new Color(this);
colorObj.setRGB(0x000000);
this.onRollOver = function() {
if (colorObj.getRGB() != 0xFF0000) {
colorObj.setRGB(0x009900);
}
};
this.onRollOut = function() {
if (colorObj.getRGB() == 0x009900) {
colorObj.setRGB(0x000000);
}
};
this.onPress = function() {
if (colorObj.getRGB() == 0x009900) {
colorObj.setRGB(0xFF0000);
} else {
colorObj.setRGB(0x009900);
}
};[/AS]

Untested, but it’s a point in the right direction none-the-less.

woah posted at same time, i have to run for a bit hopefully your code will help me out later

thanks a lot bro

omg all these posts at same time, thanks LIB and thanks Granps

you guys rock