famicomboy Posted August 23, 2012 Share Posted August 23, 2012 So I need to just tween a color property of a Starling Display Object, but can't figure a way to do it with multiple objects. Right now, I have it working, but it only works on one TweenMax at a time as I need to assign it to a variable in order to get the current progress. Is there a way I could modify the TweenMax.to() function to get it to tween hex numbers correctly? onUpdate: tweenColorUpdate, onUpdateParams: [b, b.color, 0xB2B2B2] private function tweenColorUpdate(b:BlueCube, fromColor:Number, toColor:Number):void { b.color = DataModel.interpolateColor(fromColor, toColor, cubeColorTweenMax.currentProgress); } public static function interpolateColor(fromColor:uint, toColor:uint, progress:Number):uint { var q:Number = 1-progress; var fromA:uint = (fromColor >> 24) & 0xFF; var fromR:uint = (fromColor >> 16) & 0xFF; var fromG:uint = (fromColor >> 8) & 0xFF; var fromB:uint = fromColor & 0xFF; var toA:uint = (toColor >> 24) & 0xFF; var toR:uint = (toColor >> 16) & 0xFF; var toG:uint = (toColor >> 8) & 0xFF; var toB:uint = toColor & 0xFF; var resultA:uint = fromA*q + toA*progress; var resultR:uint = fromR*q + toR*progress; var resultG:uint = fromG*q + toG*progress; var resultB:uint = fromB*q + toB*progress; var resultColor:uint = resultA << 24 | resultR << 16 | resultG << 8 | resultB; return resultColor; } Link to comment Share on other sites More sharing options...
GreenSock Posted August 23, 2012 Share Posted August 23, 2012 I'm not a Starling guy, but couldn't you just use the hexColors plugin? Like: TweenMax.to(target, 1, {hexColors:{color:0xB2B2B2}}); And don't forget to activate the HexColorsPlugin first like: TweenPlugin.activate([HexColorsPlugin]); (you only need to activate once) You don't need to do RGBA (alpha included), do you? 1 Link to comment Share on other sites More sharing options...
famicomboy Posted August 23, 2012 Author Share Posted August 23, 2012 Oh yes, that works. Thanks man. I never knew about that plugin. Should've looked harder. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now