flash actionscript 3.0 change color

bellow is a simple example to change the color of a DisplayObject(MovieClip,Button,Sprite) in flash actionscript 3.0.


// creates a red square
var square:Shape = new Shape();
//fill the square with blue color
square.graphics.beginFill(0x0000FF);
// drow the square
square.graphics.drawRect(0, 0, 150, 150);
//add the square to stage
addChild(square);
// calling the change color function
changeColor(square,0xff0000);

//changeColor function
function changeColor(o:DisplayObject,color:Number):void {
 //create a new ColorTransform
 var newColor:ColorTransform=new ColorTransform();
 // set the color property
 newColor.color=color;
 //assign the new ColorTransform to target DisplayObject
 o.transform.colorTransform=newColor;
}

0 comments:


PHP developer Cochin |PHP developer Kerala | PHP developer India | Flash developer/programmer Cochin | Flash developer/programmer Kerala | Flash developer/programmer India | web programmer kerala |web programmer Cochin |web programmer India |web developer kerala |Web developer Cochin | Kerala PHP | PHP freelancer| flash actionscript freelancer