Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

Dynamically changing color

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:

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

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.
0
skylabel
Asked:
skylabel
  • 3
1 Solution
 
Aneesh ChopraCommented:
Hi,

just trying changing following line:
----------
_root.changeColor(this, "0xFFFF33");    
----------

replace with the following:
---------
_root.changeColor(this, 0xFFFF33);    
-----------

:-Aneesh
0
 
Aneesh ChopraCommented:
Ok
got the issue


onRollover should be onRollOver

"O" in "onRollove" should be in uppercase

Rgds
Aneesh
0
 
Aneesh ChopraCommented:
Here is the fixed code:
-----------
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");    
       }
}
----------

just copy paste it..
I just change the "onRollover" to "onRollOver"

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now