2019-7-29 zhulinan Flash
package { import flash.display.MovieClip; import flash.events.*; import flash.display.Shape; import flash.display.SpreadMethod; import flash.display.InterpolationMethod; import flash.display.GradientType; import flash.geom.Matrix; //舞台尺寸、帧率、背景色 [SWF(width = 400, height = 300, frameRate = 24, backgroundColor = 0x333333)] public class Test extends MovieClip { public function Test() { addEventListener(Event.ADDED_TO_STAGE, addedHandle); } private function addedHandle(e:Event):void { removeEventListener(Event.ADDED_TO_STAGE, addedHandle); var type:String = GradientType.RADIAL; var colors:Array = [0xFF0000, 0x000000]; var alphas:Array = [1, 1]; var ratios:Array = [0, 255]; var spreadMethod:String = SpreadMethod.PAD; var interp:String = InterpolationMethod.LINEAR_RGB; var focalPtRatio:Number = 0; var matrix:Matrix = new Matrix(); var boxWidth:Number = 100; var boxHeight:Number = 100; var boxRotation:Number = Math.PI/2; // 90° var tx:Number = 0; var ty:Number = 0; matrix.createGradientBox(boxWidth, boxHeight, boxRotation, tx, ty); var square:Shape = new Shape; square.graphics.beginGradientFill(type, colors, alphas, ratios, matrix, spreadMethod, interp, focalPtRatio); square.graphics.drawCircle(50, 50, 50); addChild(square); } } }
参考资料:https://help.adobe.com/zh_CN/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7dd7.html