Actionscript 3.0 - Using an if-statement with colorTransform

95 views Asked by At

I am assigning colors to movie clips when buttons are clicked. These movie clips are vector shapes contained within an oval shape imported from Illustrator.

Each oval has a top color, a bottom color and an edge/rail color. I want the edge color to change to a combination of the top & bottom colors based on the selection of the bottom color.

I have been trying to use a conditional statement (at the bottom of the following code) with colorTransform to do this, but am not having any luck. Any tips??

(I've included an image below to help visualize what I'm trying to do.)

//Define Red Colors
var red1:ColorTransform = new ColorTransform();
red1.color = 0xE66B5B;

//Define Blue Colors
var blue1:ColorTransform = new ColorTransform();
blue1.color = 0x00467F;

//Define Red/Blue Edge Color
var redBlue:ColorTransform = new ColorTransform();
redBlue.color = 0x1D113F;

//toggle red top colors
redDeck_btn.addEventListener(MouseEvent.CLICK, toggleRedDeck);
function toggleRedDeck(e: MouseEvent) {
    deckColor_mc.transform.colorTransform = red1;
}

//toggle blue bottom colors
blueBtm_btn.addEventListener(MouseEvent.CLICK, toggleBlueBtm);
function toggleBlueBtm(e: MouseEvent) {
    btmColor_mc.transform.colorTransform = blue1;
    
    //deck = red, rails = purple color
    if (deckColor_mc.transform.colorTransform == red1){
    deckRail1_mc.transform.colorTransform = redBlue;
    btmRail_mc.transform.colorTransform = redBlue;
        }else{
            deckRail1_mc.transform.colorTransform = redBlue;
            btmRail_mc.transform.colorTransform = redBlue;
            }
}

enter image description here

1

There are 1 answers

1
Patang On

You need to compare the color property of the colorTransform Objects, like so:

deckColor_mc.transform.colorTransform.color == red1.color