# Changing colour of clips on stage via AS

**URL:** <https://forum.kirupa.com/t/changing-colour-of-clips-on-stage-via-as/205026>\
**Category:** flash\
**Created:** [October 25, 2006, 2:07pm UTC](https://forum.kirupa.com/t/changing-colour-of-clips-on-stage-via-as/205026 "2006-10-25T14:07:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oli\_G](https://avatars.discourse-cdn.com/v4/letter/o/f05b48/32.png) [@Oli\_G](https://forum.kirupa.com/u/Oli_G)\
**Post date:** [October 25, 2006, 2:07pm UTC](https://forum.kirupa.com/t/changing-colour-of-clips-on-stage-via-as/205026/1 "2006-10-25T14:07:22Z")

</div>

Yikes, should have posted here in the first place. Feel free to delete previous thread if necessary modereenoes…

Thanks very much to TheCanadian to scratching this up. Isn’t quite there though, i’m missing something small, and as usual, appears to be fine to me! So can’t quite pick it.

I have 20 odd little swfs, each of which will be loaded into a body swf at one point or another.

Each of these contains anywhere between 4 and 20 single-colour buttons. What I need is for each of them to simply change colour when rolled over/out.

The naming convention is just b1,b2 etc depending on how many said buttons are in each clip.

Suggestions?

Cheers

```auto
this.i = 0;
while(this["b" + (i++)]) {
    this["b" + i].onRollOver = function():Void {
       this.colour.setRGB(0x5FBEFE)
    }
    this["b" + i].onRollOut = function():Void {
        this.colour.setRGB(0x139FFD)
    }
}
delete this.i;

```

---

<div class="post-metadata">

**Author:** ![Sinister\_Rouge](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@Sinister\_Rouge](https://forum.kirupa.com/u/Sinister_Rouge)\
**Post date:** [October 25, 2006, 2:13pm UTC](https://forum.kirupa.com/t/changing-colour-of-clips-on-stage-via-as/205026/2 "2006-10-25T14:13:28Z")

</div>

try prefacing the [before the this with a dot. e.g. this.[“b” + i] and see if that makes a difference.

---

<div class="post-metadata">

**Author:** ![Oli\_G](https://avatars.discourse-cdn.com/v4/letter/o/f05b48/32.png) [@Oli\_G](https://forum.kirupa.com/u/Oli_G)\
**Post date:** [October 25, 2006, 2:16pm UTC](https://forum.kirupa.com/t/changing-colour-of-clips-on-stage-via-as/205026/3 "2006-10-25T14:16:15Z")

</div>

Thanks mate, but no dice, syntax error…

---

<div class="post-metadata">

**Author:** ![Oli\_G](https://avatars.discourse-cdn.com/v4/letter/o/f05b48/32.png) [@Oli\_G](https://forum.kirupa.com/u/Oli_G)\
**Post date:** [October 25, 2006, 3:31pm UTC](https://forum.kirupa.com/t/changing-colour-of-clips-on-stage-via-as/205026/4 "2006-10-25T15:31:55Z")

</div>

this.i = 0;  
while(this[“b” + (++this.i)]) {  
this[“b” + this.i].onRollOver = function():Void {  
myColor = new Color(this);  
myColor.setRGB(0x5FBEFE);  
}  
this[“b” + this.i].onRollOut = function():Void {  
myColor = new Color(this);  
myColor.setRGB(0x139FFD);  
}  
}  
delete this.i;

Problem solved 🙂
