Skip to Content About Archive Belief Contact Pudding Search


how to: control movieclip color from css


Thursday, January 31, 2008

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.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
Might Be Related

Leave a Reply


In order to submit a comment, you need to mention your name and your email address (which won't be published). And ... don't forget your comment!

Comment Form