# \[FMX\] Simplifying setRGB

**URL:** <https://forum.kirupa.com/t/fmx-simplifying-setrgb/34902>\
**Category:** flash\
**Created:** [November 7, 2003, 6:26pm UTC](https://forum.kirupa.com/t/fmx-simplifying-setrgb/34902 "2003-11-07T18:26:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maizoon](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@Maizoon](https://forum.kirupa.com/u/Maizoon)\
**Post date:** [November 7, 2003, 6:26pm UTC](https://forum.kirupa.com/t/fmx-simplifying-setrgb/34902/1 "2003-11-07T18:26:20Z")

</div>

Is there an uber easier way of doing this?

I have 5 buttons, when you release a button I want it to stay red and the others go back to white. Right now I have this script on each of my buttons:

[AS]  
btnOne.onRelease = function() {  
myColor = new Color(btnOne);  
myColor.setRGB(0xFF0000);  
myColor = new Color(btnTwo);  
myColor.setRGB(0x000000);  
myColor = new Color(btnThree);  
myColor.setRGB(0x000000);  
myColor = new Color(btnFour);  
myColor.setRGB(0x000000);  
myColor = new Color(btnFive);  
myColor.setRGB(0x000000);  
};  
btnTwo.onRelease = function() {  
myColor = new Color(btnOne);  
myColor.setRGB(0x000000);  
myColor = new Color(btnTwo);  
myColor.setRGB(0xFF0000);  
myColor = new Color(btnThree);  
myColor.setRGB(0x000000);  
myColor = new Color(btnFour);  
myColor.setRGB(0x000000);  
myColor = new Color(btnFive);  
myColor.setRGB(0x000000);  
};  
[/AS]

So on and so forth for each button…Is there a simpler way of doing this or do I Have to put these 10 lines of code into each button?

---

<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:** [November 7, 2003, 8:44pm UTC](https://forum.kirupa.com/t/fmx-simplifying-setrgb/34902/2 "2003-11-07T20:44:43Z")

</div>

yeah there is an easier way.

name your buttons like this btn0, btn1, btn2…

then use this AS on each button:

```auto
onRelease = function(){
for(i=0;i<10;i++){
myColor = new Color(["btn"+i]);
myColor.setRGB(0x000000);
}
myColor = new Color(this);
myColor.setRGB(0xFF0000);
}

```

---

<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:** [November 8, 2003, 6:49am UTC](https://forum.kirupa.com/t/fmx-simplifying-setrgb/34902/3 "2003-11-08T06:49:24Z")

</div>

isn’t white 0xFFFFFF

not real important but if your buttons keep turning out black thats why.

---

<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:** [November 8, 2003, 8:33am UTC](https://forum.kirupa.com/t/fmx-simplifying-setrgb/34902/4 "2003-11-08T08:33:11Z")

</div>

heh, yeah, white is 0xFFFFFF… just copying what he had - my bad.
