Solved

Dynamically changing color

Posted on 2006-06-30
3
243 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

628 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