# \[FMX\] need help with colour please!

**URL:** https://forum.kirupa.com/t/fmx-need-help-with-colour-please/17585
**Category:** Uncategorized
**Created:** [April 7, 2003, 8:00am UTC](https://forum.kirupa.com/t/fmx-need-help-with-colour-please/17585 "2003-04-07T08:00:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![redd](https://avatars.discourse-cdn.com/v4/letter/r/3ab097/32.png) [@redd](https://forum.kirupa.com/u/redd)
#### Post date: [April 7, 2003, 8:00am UTC](https://forum.kirupa.com/t/fmx-need-help-with-colour-please/17585/1 "2003-04-07T08:00:17Z")

</div>

I have a movie clip called “over”. I have created 4 instances named over1, over2, over3 and over4

I have 4 text fields called workscroll1 - 4

I want to set the colour of the over MC’s to white and the colour of the text fields to a colour I have created elsewhere in the site ( called menuTextStyleUp1)

Below is the code i have used and while it works ok, i have quite a few instances in the site where I am doing similar things

skinWorkAreaOver1 = new Color(\_root.over1);  
skinWorkAreaOver2 = new Color(\_root.over2);  
skinWorkAreaOver3 = new Color(\_root.over3);  
skinWorkAreaOver4 = new Color(\_root.over4);

skinWorkAreaOver1.setRGB(\_global.white); // set colour of mouse over box to no colour  
skinWorkAreaOver2.setRGB(\_global.white); // set colour of mouse over box to no colour  
skinWorkAreaOver3.setRGB(\_global.white); // set colour of mouse over box to no colour  
skinWorkAreaOver4.setRGB(\_global.white); // set colour of mouse over box to no colour

\_root.workscroll1.setTextFormat (\_root.menuTextStyleUp1); // change the colour of the text to the default colour  
\_root.workscroll2.setTextFormat (\_root.menuTextStyleUp1); // change the colour of the text to the default colour  
\_root.workscroll3.setTextFormat (\_root.menuTextStyleUp1); // change the colour of the text to the default colour  
\_root.workscroll4.setTextFormat (\_root.menuTextStyleUp1); // change the colour of the text to the default colour

Could someone help me to put this into a loop.

I have looked at some of the tutorials on this site and tried the following but get errors

i = 4;  
while (i \> 0) {  
eval(“skinWorkAreaOver” +i) = new Color(\_root[“over” +i]);  
eval(“skinWorkAreaOver” +i).setRGB(\_global.white);  
\_root.workscroll1.setTextFormat \_root[“menuTextStyleUp” +i]);  
i–;  
}

:cyclops:

---

<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: [April 7, 2003, 9:45am UTC](https://forum.kirupa.com/t/fmx-need-help-with-colour-please/17585/2 "2003-04-07T09:45:15Z")

</div>

try this:

```auto
for (k=1; k<=4; k++) {
	this["skinWorkAreaOver"+k] = new Color(this["over"+k]);
	this["skinWorkAreaOver"+k].setRGB(_global.white);
	this["workscroll"+k].setTextFormat(this["menuTextStyleUp"+k]);
}

```

:-\

---

<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: [April 7, 2003, 11:00am UTC](https://forum.kirupa.com/t/fmx-need-help-with-colour-please/17585/3 "2003-04-07T11:00:41Z")

</div>

thanks heaps kax

the code worked fine (fla attached) and should stop my code becoming spaghetti

are you able to tell me a bit about how the “this” works (or point me to a resource)

i have read the flash help file but am not really any wiser

redd

---

<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: [April 7, 2003, 11:14am UTC](https://forum.kirupa.com/t/fmx-need-help-with-colour-please/17585/4 "2003-04-07T11:14:21Z")

</div>

i think if you look in the tutorials section in actionscript, there something about ‘this’. i’ll see if i can get you the link in a sec

---

<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: [April 7, 2003, 11:15am UTC](https://forum.kirupa.com/t/fmx-need-help-with-colour-please/17585/5 "2003-04-07T11:15:31Z")

</div>

[http://www.kirupa.com/developer/actionscript/tricks/root\_parent\_this.asp](http://www.kirupa.com/developer/actionscript/tricks/root_parent_this.asp)

i think that should explain it

---

<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: [April 7, 2003, 11:39am UTC](https://forum.kirupa.com/t/fmx-need-help-with-colour-please/17585/6 "2003-04-07T11:39:18Z")

</div>

there’s something i’d like to mention…

the script in a button, is referenced to the timeline, not to the button.  
so if you ever use the same script in a movie clip, you’ll need to change **this** to **\_parent** 😉

[http://www.macromedia.com/support/flash/action\_scripts/actionscript\_dictionary/actionscript\_dictionary806.html](http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary806.html)
