ColorTransform
- danBuonocore
-
danBuonocore
- Member since: Aug. 24, 2011
- Offline.
-
- Forum Stats
- Member
- Level 03
- Game Developer
Is there a way to change a MovieClip's color without creating a new ColorTransform object? Something along the lines of
transform.colorTransform.redOffset = 100;
instead of
var ct:ColorTransform = new ColorTransform();
ct.redOffset = 100;
transform.colorTransform = ct;
Thanks!
- MSGhero
-
MSGhero
- Member since: Dec. 15, 2010
- Offline.
-
- Forum Stats
- Supporter
- Level 16
- Game Developer
At 12/7/13 02:19 PM, danBuonocore wrote: Is there a way to change a MovieClip's color without creating a new ColorTransform object?
ct = transform.colorTransform;
ct.redOffset = 100;
transform.colorTransform = ct;
transform.colorTransform creates a new colortransform object anyway, so you don't have to make another new one.
- Sam
-
Sam
- Member since: Oct. 1, 2005
- Offline.
-
- Forum Stats
- Moderator
- Level 19
- Programmer
Additionally you could just compact it into a single line by using the ColorTransform constructor, if you want:
transform.colorTransform = new ColorTransform(1, 1, 1, 1, 255, 255, 255, 255); - kkots
-
kkots
- Member since: Apr. 16, 2013
- Offline.
-
- Forum Stats
- Supporter
- Level 10
- Blank Slate
At 12/7/13 02:19 PM, danBuonocore wrote: Is there a way to change a MovieClip's color without creating a new ColorTransform object? Something along the lines of
transform.colorTransform.redOffset = 100;
YES
setRedColor(mc,100);
function setRedColor(mc:DisplayObject, clr:uint, temp_obj:ColorTransform=null):void{
mc.transform.colorTransform=(temp_obj=mc.transform.colorTransform)==(temp_obj.redOffset=clr)?temp_obj;
}
Haha. Not really. Follow Sam's advice.

