开发者

Flash - ActionScript - Change fill color of a button in code

开发者 https://www.devze.com 2022-12-30 15:29 出处:网络
ActionScript 3 - CS5 I\'m new to Flash and wondering how to change fill color from code. Something like this -

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消