In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: flash on 2010-2-24

剑归宗
夏天的树人
Get Adobe Flash player
by summerTree 01 Mar 2010
    Embed
/**
 * Copyright summerTree ( http://wonderfl.net/user/summerTree )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/tk1s
 */

package 
{
	//剑归宗
    //夏天的树人 
	import flash.display.Sprite;
	import flash.events.*;
	import flash.display.DisplayObject;
	import flash.utils.Timer;

	public class Main extends Sprite
	{
		private var list:Array=new Array();
		private var Speed:int=4;//飞行速度
		private var contain:Sprite=new Sprite();
		private var num:int=20;
		//private var timer:Timer;
		public function Main()
		{
			addChild(contain);
			stage.addEventListener(MouseEvent.CLICK,onClick);
		   // timer=new Timer(200);
			//timer.addEventListener(TimerEvent.TIMER,onTimer);
		}
		
		
		
		
		//创建一把剑
		private function onClick(event:MouseEvent):void
		{
			while (list.length>0)
			{
				list.pop();
			}
			for (var i:int=0; i<num; i++)
			{
				var mysword:Sword=new Sword();
				contain.addChild(mysword);
				mysword.x=mouseX+Math.cos(i*2*Math.PI/num)*150;
				mysword.y=mouseY+Math.sin(i*2*Math.PI/num)*150;
				list.push(mysword);
				var angle:Number=Math.atan2(mouseY-mysword.y,mouseX-mysword.x);//角度
				mysword.angle=angle;
				mysword.rotation=angle*180/Math.PI-90;			
				mysword.addEventListener(Event.ENTER_FRAME,Run);//进行运动
			}

		}
		//运动
		private function Run(event:Event):void
		{
			var vx:Number=Math.cos(event.currentTarget.angle)*Speed;
			var vy:Number=Math.sin(event.currentTarget.angle)*Speed;
			event.currentTarget.x+=vx;
			event.currentTarget.y+=vy;
			if (event.currentTarget.x>stage.stageWidth||event.currentTarget.x<0||event.currentTarget.y<0||
			event.currentTarget.y>stage.stageHeight
			)
			{   if(event.currentTarget!=null)
			   {
				event.currentTarget.removeEventListener(Event.ENTER_FRAME,Run);
				contain.removeChild(DisplayObject(event.currentTarget));
			   }
			}
		}
	}
}

import flash.display.Sprite;
//描绘一把剑
internal class Sword extends Sprite
{
	private var pen:Sprite=new Sprite();
	public var angle:Number=0;
	private var array:Array=[ [50,0],
	  [50,50],
	  [20,50],
	  [20,60],
	  [45,60],
	  [45,300],
	  [65,330],
	  [75,300],
	  [75,60],
	  [105,60],
	  [105,50],
	  [70,50],
	  [70,0],
	  [50,0]
	 ];
	public function Sword()
	{
		init();
	}
	private function init():void
	{
		addChild(pen);
		pen.graphics.lineStyle(1,0x000000);
		pen.graphics.moveTo(array[0][0],array[0][1]);
		for (var i:int=0; i<array.length; i++)
		{
			pen.graphics.lineTo(array[i][0],array[i][1]);
		}
		pen.graphics.drawCircle(60,-11,12);//绘制剑中心
		pen.graphics.drawCircle(60,60,14);
		pen.graphics.beginFill(0xff00ff);
		pen.graphics.drawCircle(60,60,5);
		pen.graphics.endFill();
		pen.graphics.moveTo(60,60);
		pen.graphics.lineTo(65,330);
		pen.scaleX=pen.scaleY=0.3;
	}
}