以下类可直接作为文档类测试,效果如图:
1 package 2 { 3 import fl.motion.Color; 4 import flash.display.GradientType; 5 import flash.display.Shape; 6 import flash.display.Sprite; 7 import flash.events.MouseEvent; 8 import flash.geom.Matrix; 9 10 /**11 * ...12 * @author FrostYen13 */14 [SWF(width=700,height=800,backgroundColor=0x000000)]15 public class GradientColor extends Sprite16 {17 public function GradientColor():void18 {19 setGradient(0xDFB920, 0x0000FF,70);20 }21 22 /**23 * 绘制从一种颜色过渡到另一种颜色的色块24 * @param fromColor 开始颜色值25 * @param toColor 最终颜色值26 * @param total 色块数量27 */28 public function setGradient(fromColor:uint,toColor:uint,total:int):void29 {30 for (var i:int=0; i