Change the Petals on the Flower


Get Adobe Flash player

The flower movie clip contains a movie clip called colorArea that is just the fill from the petals. The buttons are named btnBlue, bthRed, btnYellow and btnPurple.

The code is shown below:

btnBlue.addEventListener(MouseEvent.CLICK,changeColor);
btnRed.addEventListener(MouseEvent.CLICK,changeColor);
btnYellow.addEventListener(MouseEvent.CLICK,changeColor);
btnPurple.addEventListener(MouseEvent.CLICK,changeColor);
function changeColor(e:MouseEvent):void {
   var colorT:ColorTransform = new ColorTransform();
   switch(e.target.name) {  //which button was clicked?
      case "btnBlue": colorT.color=0x0000FF; break; //blue in hexadecimal
      case "btnRed": colorT.color=0xFF0000; break; //red in hexadecimal
      case "btnYellow": colorT.color=0xFFFF00; break; //yellow in hexadecimal
      case "btnPurple": colorT.color=0xFF00FF; break; //purple in hexadecimal
   } //switch
   flower.colorArea.transform.colorTransform = colorT; //change the color of the box
} //changeColororTransform = colorT; //change the color of the box
} //changeColor
Download movie
INDEX, Change the Color: ColorTransform, Prepare a Flower for changing petal color, Change the color of the Flower, Color Picker Component, Pick Color with ColorPicker Component, A Random Color, A Random Color with a lighter and darker shading, Shading the Flower with a ColorPicker, Random Shades of a Color
Next lesson: Components

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Change the color of the Flower