If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
So I needed to change a movieclip’s color at runtime using css. Seemed pretty simple i thought, and i was right. flash converts the css color property to a number, and we only need to pass a number to color transform.
below is an example function. we retrieve the color property of our style, an do a color transform on our target movieclip. end result? css controlled movieclip colors.
import flash.geom.Transform;
import flash.geom.ColorTransform;
import TextField.StyleSheet
function colorFromStyle( styleName:String , stylesObject:StyleSheet , targetMc:MovieClip ){
var colorCode:Number=stylesObject['_styles'][styleName].color
var colorChange:Transform=new Transform(targetMc)
var colorObject:ColorTransform=new ColorTransform()
colorObject.rgb=colorCode
colorChange.colorTransform=colorObject
}
elsid out
Powered by ScribeFire.
Might Be Related




