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:
Post a Comment