Solved

Dynamically changing color

Posted on 2006-06-30
3
239 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
ID: 17022423
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
ID: 17022430
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
ID: 17022437
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

948 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

23 Experts available now in Live!

Get 1:1 Help Now