AS3 colorTransform over multiple frames?

(Flash Professional, AS3)

I'm working on a custom avatar system where you can select various festures and colors. For example, I have a "hair" movieclip that has 10 hairstyles. Each frame has a movieclip of a different hairstyle (HairStyle1, HairStyle2, etc.). I also have a colorPicker to change the color.

Here's my code:

var hairColor:ColorTransform;
hairColor =; 
hairColor.color = 0xCCCC00; = hairColor;

This correctly changes the initial color. I have a "nextHair" button to advance to the next frame. When I click the button, I get an error message saying that I have a null object reference. I added a trace, and is null on frame 2. Why??? I've clearly named HairStyle2 as "colorLayer" in frame 2.

I think the problem is related to me using the same name for different classes/movieclips, but I don't know how to fix the problem...

I added a square movieclip below my hairStyle movieclips, named the square "colorLevel", and deleted the name from my hairStyle clips. When I click the next button, the square correctly maintains the color from frame to frame. However, having a square doesn't do me much good. :(

I tried converting the hairStyle layer to a mask. Doing this, however, results in yet another "null object" error - is null after frame 1. I even tried "spanning" my colorLevel across all frames (no keyframes), thinking that this would give me just one movieclip to work with. No luck. Same error!

What's going on, here? Why am I getting these null objects, when they are clearly defined in my movieclip?

I'm also open to suggestions on a better way to do multiple frames and colors.


function miClick(e:MouseEvent) {

    if( == "2") {
        content.addEventListener(Event.EXIT_FRAME, this.hdExitFrame);
        productMenu.alpha = 1;
    } else {
        productMenu.alpha = 0;

function hdExitFrame(e:Event) {
    trace( + ", " +;
    content.removeEventListener(Event.EXIT_FRAME, this.hdExitFrame);

I've tested this, content.products is null in miClick, however, in hdExitFrame, it was not. Hope this helps.

Need Your Help

how to draw a circle shape in excel by using apache POI

java excel apache-poi

I like to draw the circle shape in excel by using apache POI. i have following code. there is not error when i run this code. but when i open the outputted excel file, it say "File error: data may ...

UFT / QTP : unable to access Object.CurrentStyle in Firefox

vbscript qtp hp-uft

I used below code, for fetching the font size of a "link" on IE.