Changing color of movie clip in AS3

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

LVL 9
jkunreinAsked:
Who is Participating?
 
blue-genieConnect With a Mentor Commented:
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 ==

blu

0
 
jkunreinAuthor Commented:
Adding more zones and points to the question.
0
 
jkunreinAuthor Commented:
Oh, of course!  I keep forgetting that.  Well, another dozen mistakes like this, and I should have this down perfect.  Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.