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

twinkle

Get Adobe Flash player
by Scmiz 18 Jun 2011
    Embed
/**
 * Copyright Scmiz ( http://wonderfl.net/user/Scmiz )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/z46a
 */

package {
    import flash.display.Sprite;
	import flash.events.Event;

    public class FlashTest extends Sprite {
        public function FlashTest() {
			this.graphics.beginFill(0x000040);
			this.graphics.drawRect(0, 0, 465, 465);
			this.graphics.endFill();
			
			this.addEventListener(Event.ENTER_FRAME, proc)
        }
		
		private function proc(e:Event):void {
			for (var index:uint = 0; index < 2; ++index) {
				var star:Star = this.addChild(new Star()) as Star;
				star.x = Math.random() * 1000;
				star.y = -80;
			}
		}
    }
}

import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;

class Star extends Sprite {
	private var _size:Number;
	private var _speed:Number;
	
	public function Star() {
		_size = 5 + (Math.random() * 5);
		_speed = 1 + (Math.random() * 2)
		
		var g:Graphics = this.graphics;
		g.beginFill(0xffff40);
		var lengthMin:Number = _size * 0.55;
		var lengthMid:Number = _size * 0.85;
		var lengthMax:Number = _size * 1.0;
		var rad:Number = ( -Math.PI * 0.5) + (Math.PI * 0.2);
		g.moveTo(Math.cos(rad) * lengthMin, Math.sin(rad) * lengthMin);
		for (var index:uint = 0; index < 5; ++index) {
			rad += Math.PI * 0.16;
			g.lineTo(Math.cos(rad) * lengthMid, Math.sin(rad) * lengthMid);
			rad += Math.PI * 0.04;
			var ctrlX:Number = Math.cos(rad) * lengthMax;
			var ctrlY:Number = Math.sin(rad) * lengthMax;
			rad += Math.PI * 0.04;
			g.curveTo(ctrlX, ctrlY, Math.cos(rad) * lengthMid, Math.sin(rad) * lengthMid);
			rad += Math.PI * 0.16;
			g.lineTo(Math.cos(rad) * lengthMin, Math.sin(rad) * lengthMin);
		}
		g.endFill();
		
		this.addEventListener(Event.ENTER_FRAME, proc);
	}
	
	private function proc(e:Event):void {
		this.rotationZ -= _speed * 0.5;
		
		this.x -= _speed;
		this.y += _speed;
		
		if (this.x < -_size || this.y > 465 + _size) {
			parent.removeChild(this);
			this.removeEventListener(Event.ENTER_FRAME, proc);
		}
	}
}