Solved

Dynamically changing color

Posted on 2006-06-30
3
238 Views
Last Modified: 2009-12-16
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
Comment
Question by:skylabel
  • 3
3 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
Comment Utility
Hi,

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

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

:-Aneesh
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
Comment Utility
Ok
got the issue


onRollover should be onRollOver

"O" in "onRollove" should be in uppercase

Rgds
Aneesh
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 500 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now