# Set Transform Color Issue

**URL:** <https://forum.kirupa.com/t/set-transform-color-issue/30199>\
**Category:** flash\
**Created:** [September 5, 2003, 2:15am UTC](https://forum.kirupa.com/t/set-transform-color-issue/30199 "2003-09-05T02:15:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2003, 2:15am UTC](https://forum.kirupa.com/t/set-transform-color-issue/30199/1 "2003-09-05T02:15:00Z")

</div>

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)

```auto

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

	}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2003, 2:42am UTC](https://forum.kirupa.com/t/set-transform-color-issue/30199/2 "2003-09-05T02:42:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2003, 2:46am UTC](https://forum.kirupa.com/t/set-transform-color-issue/30199/3 "2003-09-05T02:46:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2003, 2:46am UTC](https://forum.kirupa.com/t/set-transform-color-issue/30199/4 "2003-09-05T02:46:19Z")

</div>

[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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2003, 2:49am UTC](https://forum.kirupa.com/t/set-transform-color-issue/30199/5 "2003-09-05T02:49:48Z")

</div>

You can use getRGB() and setRGB(), much shorter 😉

[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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2003, 2:51am UTC](https://forum.kirupa.com/t/set-transform-color-issue/30199/6 "2003-09-05T02:51:57Z")

</div>

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

thanks a lot bro

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 5, 2003, 3:00am UTC](https://forum.kirupa.com/t/set-transform-color-issue/30199/7 "2003-09-05T03:00:44Z")

</div>

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

you guys rock
