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: Mouse Toy

Get Adobe Flash player
by undo 05 May 2010
/**
 * Copyright undo ( http://wonderfl.net/user/undo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/c5x2
 */

// forked from shapevent's Mouse Toy
package {

	import flash.display.*;
	import flash.events.*;


	

       public class MouseToy extends MovieClip {
		private var hCircles:Array;
		private var vCircles:Array;


               public function MouseToy(){
                  // init
			vCircles = [];
			hCircles = [];
			for (var i:int = 0; i<30; i++){
				//横長
				var vc:Sprite = makeCircle();
				vc.x = stage.stageWidth / 2;
				vc.y = stage.stageHeight / 2;
				vc.scaleX = 1 + i/2;
				vc.scaleY = 0.5 + i/4;
				addChild(vc);
				vCircles.push(vc);
				//縦長
				var hc:Sprite = makeCircle();
				hc.x = stage.stageWidth / 2;
				hc.y = stage.stageHeight / 2;
				hc.scaleX = 0.5 + i/4;
				hc.scaleY = 1 + i/2;
				addChild(hc);
				hCircles.push(hc);
			}
			addEventListener(Event.ENTER_FRAME, onLoop);
			
			
			
			

               }
               // private methods

		private function onLoop(evt:Event):void {
			vCircles[0].y += (mouseY - vCircles[0].y) / 4;
			hCircles[0].scaleX = Math.cos(vCircles[0].y*Math.PI/180)*hCircles[0].scaleY;			
			for (var i:int = 1; i<vCircles.length; i++){
				var vpre:Sprite = vCircles[i - 1];
				vCircles[i].y += (vpre.y - vCircles[i].y) / 4;
				hCircles[i].scaleX = Math.cos(vCircles[i].y*Math.PI/180)*hCircles[i].scaleY;
			}
		}
		private function makeCircle():Sprite{
			var s:Sprite = new Sprite();
			with(s.graphics){
				lineStyle(0,0x000000);
				drawCircle(0,0,10);
			}
			return s;
		}
		

       }

}