Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Dynamically changing color

Posted on 2006-06-30
3
Medium Priority
?
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

715 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