⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 starshape.as

📁 《Flash AS3殿堂之路》光盘源码 学习ActionScript 3.0
💻 AS
字号:
/*
the core logic comes from Ric Ewing's AS1 work.
*/

package org.kingda.book.display
{
	import flash.display.Shape;
	import flash.display.GradientType;

	public class StarShape extends Shape
	{
		public function StarShape(x:Number=0, y:Number=0, 
									points:int=5, innerRadius:Number=20, 
									outerRadius:Number=50, angle:Number=0, color:uint=0xff0000) {
			
			var count = Math.abs(points);
			this.graphics.lineStyle(2, 0x85DB18);
			
			//开始填色
			this.graphics.beginFill(color);
			if (count>2) {
				// init vars
				var step, halfStep, start, n, dx, dy;
				//计算两点之间距离
				step = (Math.PI*2)/points;
				halfStep = step/2;
				//起始角度
				start = (angle/180)*Math.PI;
				this.graphics.moveTo(x+(Math.cos(start)*outerRadius), y-(Math.sin(start)*outerRadius));
				//画星状图的边
				for (n=1; n<=count; n++) {
					dx = x+Math.cos(start+(step*n)-halfStep)*innerRadius;
					dy = y-Math.sin(start+(step*n)-halfStep)*innerRadius;
					this.graphics.lineTo(dx, dy);
					dx = x+Math.cos(start+(step*n))*outerRadius;
					dy = y-Math.sin(start+(step*n))*outerRadius;
					this.graphics.lineTo(dx, dy);
				}
			}
			this.graphics.endFill();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -