Changing color of movie clip in AS3

Posted on 2008-11-05
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 ( = "amalgam_mc")


		trace("Target recogized as amalgam_mc");

		activeColor.color  = 0x0000FE;




function toothClick(event:MouseEvent):void


	trace("Click is fired");

	if ( = "tooth01_mesial_mc")


		trace("Target recognized as tooth01_mesial_mc");

		tooth01_mesial_mc.transform.colorTransform = activeColor;



Open in new window

Question by:jkunrein
    LVL 9

    Author Comment

    Adding more zones and points to the question.
    LVL 39

    Accepted Solution

    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 ( = "amalgam_mc")//2 instances
    need to be ==


    LVL 9

    Author Comment

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

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Order table with macro 3 67
    bigHeights  challenge 13 43
    count8 challlenge 13 69
    changePi Challenge 15 57
    This article will show, step by step, how to integrate R code into a R Sweave document
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    746 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

    16 Experts available now in Live!

    Get 1:1 Help Now