The official docs say:
You must use the new ColorTransform() constructor to create a ColorTransform object before you can call the methods of the ColorTransform object.
So does this mean every time I want to tweak the color transform, I have to create a new instance? If so, the setter properties seem pretty pointless and my tests are showing this is the case.
So if eve开发者_开发知识库ry render I want to cycle say the redOffset
based on time (to get a pulsing effect), do I have to manually create a new ColorTransform
passing all constructor args from this.transform.colorTransform
:
var newRedOffset:Number = ...
transform.colorTransform = new ColorTransform(
transform.colorTransform.redMultiplier, transform.colorTransform.greenMultiplier,
transform.colorTransform.blueMultiplier, transform.colorTransform.alphaMultiplier,
newRedOffset, transform.colorTransform.greenOffset,
transform.colorTransform.blueOffset, transform.colorTransform.alphaOffset );
It seems horrible, is there a shortcut?
rather than dealing with color multipliers and alpha offsets, here's a simple, straight forward way to change the color of a display object:
var ct:ColorTransform = new ColorTransform();
ct.color = 0xFF0000; //Simple Hex Color value
myDisplayObject.transform.colorTransform = ct;
this way you can change the color property of the same ColorTransform object and then reapply it to your display object.
No, it doesn't. You can use the colorTransform the object already has, but you need to reassign it after you have changed the values:
var trans:ColorTransform = sprite.transform.colorTransform;
trans.blueOffset += 10;
sprite.transform.colorTransform = trans;
精彩评论