ActionScript 3 - CS5
I'm new to Flash and wondering how to change fill color from code. Something like this -
btnRed.fillColor = "0xff开发者_如何学Python0000";
Thank you for your comment!
Look into ColorTransform. All DisplayObject (i.e. Sprite, MovieClip, Shape, etc.) has a property called transform, which in turns contains a property called ColorTransform.
The code below makes it so a square with black fill color is changed to green:
var square:Shape = new Shape(); square.graphics.beginFill(0x000000); square.graphics.drawRect(0, 0, 200, 200); var ct:ColorTransform = square.transform.colorTransform; ct.color = 0x00FF00; square.transform.colorTransform = ct; addChild(square);
精彩评论