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

flash on 2010-4-5

2010年4月5日
こんな感じのスプリングのオモチャがあったような...
Get Adobe Flash player
by tenasaku 05 Apr 2010
/**
 * Copyright tenasaku ( http://wonderfl.net/user/tenasaku )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qnkE
 */

// 2010年4月5日
// こんな感じのスプリングのオモチャがあったような...

package {
    import flash.display.*;
    import flash.events.*;
    public class FlashTest extends Sprite {
    		private const N:int = 55;
    		private var tunnel:Array;
    		private function atEveryFrame(e:Event):void {
    			var i:int;
    			for ( i = 0 ; i < N ; ++i ) {
    				tunnel[i].x = (i/(i+1))*tunnel[i+1].x + (1/(i+1))*stage.stageWidth/2;
    				tunnel[i].y = (i/(i+1))*tunnel[i+1].y + (1/(i+1))*stage.stageHeight/2;
    			}
    			tunnel[N].x = this.mouseX;
    			tunnel[N].y = this.mouseY;
    		}
    		private function onResize(e:Event):void {
    			this.graphics.clear();
    			this.graphics.beginFill(0x000000);
    			this.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
    			this.graphics.endFill();
    		}
    		private function initialize(e:Event):void {
    			stage.align = StageAlign.TOP_LEFT;
    			stage.scaleMode = StageScaleMode.NO_SCALE;
    			this.graphics.clear();
    			this.graphics.beginFill(0x000000);
    			this.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
    			this.graphics.endFill();
    			tunnel = new Array;
    			var i:int;
    			for ( i = 0 ; i <= N ; ++i ) {
    				var theta:Number = i/N*Math.PI*2;
    				var red:uint = Math.floor((1+Math.cos(theta-Math.PI/3*2))*127.99);
    				var green:uint = Math.floor((1+Math.cos(theta+Math.PI/3*2))*127.99);
    				var blue:uint = Math.floor((1+Math.cos(theta))*127.99);
    				var cc:uint = (red<<16)|(green<<8)|blue;
    				tunnel[i] = new Shape();
    				tunnel[i].visible = false;
    				tunnel[i].graphics.clear();
    				tunnel[i].graphics.lineStyle(8,cc);
    				tunnel[i].graphics.drawCircle(0,0,i*4+2);
    			}
    			for ( i = 0 ;  i < N ; ++i ) {
    				++i;
    				tunnel[i].x = stage.stageWidth/2;
    				tunnel[i].y = stage.stageHeight/2;
    				this.addChild(tunnel[i]);
    				tunnel[i].visible = true;
    			}
    			tunnel[N].x = this.mouseX;
    			tunnel[N].y = this.mouseY;
    			stage.addEventListener(Event.RESIZE, onResize);
    			stage.addEventListener(Event.ENTER_FRAME, atEveryFrame);
    		}
        public function FlashTest() {
			if ( stage != null ) {
				initialize(null);
			} else {
				this.addEventListener(Event.ADDED_TO_STAGE, initialize);
			}
        }
    }
}