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: SimpleFish

author :夏天的树人
blog:http://blog.csdn.net/hero82748274
写于2010年5月19日
Get Adobe Flash player
by summerTree 19 May 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/d1Az
 */

// forked from summerTree's SimpleFish
//author :夏天的树人
//blog:http://blog.csdn.net/hero82748274
//写于2010年5月19日 
 
package 
{
	import flash.display.Sprite;
	import flash.events.*;
	import flash.utils.Timer;
	import flash.display.DisplayObject;
	import flash.filters.GlowFilter;
	public class Main extends Sprite
	{
		private var fishList:Array=new Array();
		private var speed:Number=5;
		private var count:int=0;
		private var contain:Sprite=new Sprite();
		public function Main()
		{
			init();
		}
		private function init():void
		{
			addChild(contain);
			contain.name="管理者";
			var time:Timer=new Timer(200);
			time.addEventListener(TimerEvent.TIMER,onTimer);
			time.start();
		}
		private function onTimer(event:TimerEvent):void
		{
			count++;
			var fish:SimpleFish=new SimpleFish();
			fish.addEventListener(Event.ENTER_FRAME,Run);
			fish.x=stage.stageWidth*Math.random();
			fish.y=stage.stageHeight*Math.random();

			if (count==1)
			{
				fish.scaleX=1;
				fish.speed=-Math.random()*5-1;
			}
			else if (count==2)
			{
				fish.scaleX=-1;
				fish.speed=Math.random()*5+1;
				count=0;
			}
			fish.CreatSimpleFish(60,40,3,20);//创建小鱼
			contain.addChild(fish);
			
			//添加发光的滤镜
			var filter:GlowFilter=new GlowFilter();
			filter.blurX=8;
			filter.blurY=8;
			filter.color=Math.random()*0xffffff;
			var array:Array=new Array();
			array.push(filter);
			fish.filters=array;


		}
		private function Run(event:Event):void
		{
			event.currentTarget.x+= event.currentTarget.speed;
			if (event.currentTarget.x<0||event.currentTarget.x>stage.stageWidth)
			{
                 //删除监听和对象
				if (contain.contains(DisplayObject(event.currentTarget)))
				{
					event.currentTarget.removeEventListener(Event.ENTER_FRAME,Run);

					contain.removeChild(DisplayObject(event.currentTarget));
				}
 
			}
		}
	}
}
	import flash.geom.Point;
	import flash.display.Sprite;
	internal class SimpleFish extends Sprite 
	{
		public var speed:Number;
		public function SimpleFish()
		{

		}
		public function clone():SimpleFish
		{
			return new SimpleFish();
		}
		
		//创建简单的鱼
		public function CreatSimpleFish(Width:Number,Height:Number,eyes_Width:Number=5,Fish_rear:Number=50,n:int=4):void
		{
				
		  this.graphics.lineStyle(1,0x000000);
		  this.graphics.moveTo(0,0);
		  this.graphics.curveTo(Width/2, Height, Width, 0);
		  this.graphics.moveTo(0,0);
		  this.graphics.curveTo(Width/2, -Height, Width, 0);
		  
		  this.graphics.drawCircle(Width/5,0,eyes_Width);
		  
		  this.graphics.moveTo(Width/4,-Height/2.7);		  
		  this.graphics.curveTo(Width/3, 0, Width/4, Height/2.7);
		  
		  
		  //创建鱼尾		  
		  this.graphics.moveTo( Width, 0);		  
		  this.graphics.lineTo( Width+Width/n,  Fish_rear);
		  
		  this.graphics.moveTo( Width, 0);
		  
		  this.graphics.lineTo( Width+Width/n,  -Fish_rear);
		  this.graphics.lineTo( Width+Width/n,  +Fish_rear);
			
		}
		public function clear():void
		{
			this.graphics.clear();
		}
		
	}