Changing color of movie clip in AS3

Posted on 2008-11-05
Medium Priority
Last Modified: 2013-11-11
I'm not a complete newbie, but my AS knowledge is very rudimentary.  I am trying to create code that would change the color of a movie clip.  I have the code pasted below.

Ultimately, I am creating a sort of paintbrush game.  The user clicks on a color palette (named amalgam_mc, crown_mc), which stores the associated color.  Each object that is clicked takes on that color (such as tooth01_mesial_mc, tooth02_mesial_mc, etc.).  

Unfortunately, I'm stuck at the beginning with changing the color of a movie clip.  I ask for a push in the right direction.  
import flash.geom.ColorTransform;
amalgam_mc.addEventListener(MouseEvent.CLICK, colorClick);
crown_mc.addEventListener(MouseEvent.CLICK, colorClick);
complete_denture_mc.addEventListener(MouseEvent.CLICK, colorClick);
tooth01_mesial_mc.addEventListener(MouseEvent.CLICK, toothClick);
var activeColor:ColorTransform  = new ColorTransform;
function colorClick(event:MouseEvent):void
	trace("Click is fired");
	if (event.target.name = "amalgam_mc")
		trace("Target recogized as amalgam_mc");
		activeColor.color  = 0x0000FE;
function toothClick(event:MouseEvent):void
	trace("Click is fired");
	if (event.target.name = "tooth01_mesial_mc")
		trace("Target recognized as tooth01_mesial_mc");
		tooth01_mesial_mc.transform.colorTransform = activeColor;

Open in new window

Question by:jkunrein
  • 2

Author Comment

ID: 22892297
Adding more zones and points to the question.
LVL 39

Accepted Solution

blue-genie earned 1400 total points
ID: 22892676
your code will work you just have a basic syntax error
when you assign a value to something

thisvalue = thisValue;
if you want to check if 2 values are the same

if (thisvalue == thisValue) { ...

so your code

if (event.target.name = "amalgam_mc")//2 instances
need to be ==



Author Comment

ID: 22894752
Oh, of course!  I keep forgetting that.  Well, another dozen mistakes like this, and I should have this down perfect.  Thank you.

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Loops Section Overview

864 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