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

Warp

Warp.as
Get Adobe Flash player
by kadal 03 Apr 2009
/* Warp.as */
package {
	import flash.display.*;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.geom.Matrix;

	public class Warp extends Sprite {

		private var myStar:MovieClip = new MovieClip();

		public function Warp() {

			var myBG:Sprite = new Sprite();

			var mtx:Matrix = new Matrix();
			mtx.createGradientBox(stage.stageWidth, stage.stageHeight, 0, 0, 0); 

			myBG.graphics.beginGradientFill(GradientType.RADIAL, [0x282828, 0x000000], [1, 1], [0, 255], mtx, SpreadMethod.PAD, InterpolationMethod.RGB, 0);

			myBG.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
			myBG.graphics.endFill();
			addChild(myBG);


			addChild(myStar);
			var timer:Timer = new Timer(5, 0);
			timer.addEventListener(TimerEvent.TIMER, myCircle);
			timer.start();
		}

		private function myCircle(evt:TimerEvent):void {
			var p:Sprite = new Sprite();
			p.graphics.beginFill(0xFFFFFF);
			p.graphics.drawCircle(0, 0, 3);

			var filters_array:Array = new Array();
			var myBlur:BlurFilter = new BlurFilter(3, 3, 1);
			filters_array.push(myBlur);
			p.filters = filters_array;

			var myRad:Number = Math.random()*2*Math.PI;

			p.x = stage.stageWidth * Math.cos(myRad);
			p.y = stage.stageHeight * Math.sin(myRad);

			p.graphics.endFill();
			p.alpha = 1;
			myStar.addChild(p);
			myStar.addEventListener(Event.ENTER_FRAME, rotate);
			p.addEventListener(Event.ENTER_FRAME, smaller);
		}

		private function rotate(evt:Event):void{
			myStar.x = stage.stageWidth/2;
			myStar.y = stage.stageHeight/2;
			myStar.rotation += 1;
		}

		private function smaller(evt:Event):void{
			var p:Object = evt.target;
			p.scaleX *= 0.92;
			p.scaleY *= 0.92;
			p.alpha = p.scaleX;
			p.x += (-p.x)/10;
			p.y += (-p.y)/10;
			if(p.width < 1){
				p.visible = false;
				p.removeEventListener(Event.ENTER_FRAME, smaller);
				myStar.removeChild(DisplayObject(p));
			}
		}
	}
}