Package { Import Flash.display.Sprite; Import Flash.display.GradientType; Import Flash.geom.ColorTransform; Import flash.events.MouseEvent; public class Colortransformexample extends Sprite { Public Function Colortransformexample () { var target:sprite = new Sprite (); Draw (target); AddChild (target); Target.usehandcursor = true; Target.buttonmode = true; Target.addeventlistener (Mouseevent.click, ClickHandler) } Public function Draw (Sprite:sprite): void { var red:uint = 0xff0000; var green:uint = 0x00ff00; var blue:uint = 0x0000ff; var size:number = 100; Sprite.graphics.beginGradientFill (Gradienttype.linear, [Red, blue, green], [1, 0.5, 1], [0, 200, 255]); Sprite.graphics.drawRect (0, 0, 100, 100); } Public Function ClickHandler (event:mouseevent): void { var roffset:number = Transform.colorTransform.redOffset + 25; var boffset:number = transform.colortransform.redoffset-25; This.transform.colorTransform = new ColorTransform (1, 1, 1, 1, roffset, 0, Boffset, 0); } } } |