# Dynamically changing color

**URL:** <https://forum.kirupa.com/t/dynamically-changing-color/192797>\
**Category:** flash\
**Created:** [July 1, 2006, 5:08am UTC](https://forum.kirupa.com/t/dynamically-changing-color/192797 "2006-07-01T05:08:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skylabel](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@skylabel](https://forum.kirupa.com/u/skylabel)\
**Post date:** [July 1, 2006, 5:08am UTC](https://forum.kirupa.com/t/dynamically-changing-color/192797/1 "2006-07-01T05:08:45Z")

</div>

[FONT=Trebuchet MS]Hi, I’m trying to dynamically change movieclip colors. My MovieClips (on the main timeline) are named box\_mc1, box\_mc2, box\_mc3, etc. I have the following code, but I can’t figure out why it doesn’t work. Help appreciated.

My script on Frame 1 as follows:[/FONT]

```auto

function changeColor(targetMC:MovieClip, colorCode) {
     var colorful = new Color(targetMC);
     colorful.setRGB(colorCode);
}

for (n=1; n<=3; n++) {
      this["box_mc"+n].onRollover = function () 
      {
        trace("color");
      _root.changeColor(this, "0xFFFF33");     
       }
}

```

[FONT=Trebuchet MS]I don’t quite understand why the trace statement doesn’t work either, but the mouse pointer changes to a hand when I move over the MovieClips.[/FONT]
