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 2009-5-27

本に載ってたコードを参考にしました。なんか動きが遅い
Get Adobe Flash player
by gurumi 27 May 2009
    Embed
/**
 * Copyright gurumi ( http://wonderfl.net/user/gurumi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/iHH3
 */

//本に載ってたコードを参考にしました。なんか動きが遅い
package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.display.StageScaleMode;
	import flash.geom.ColorTransform;
	
	
	[SWF(width="465", height="465", backgroundColor="0x000000")]
    
	public class CircleInteractive extends Sprite {

		private var myCircle:Circle_DocClass;
		private var circles:Array;
		private var stageW:uint = stage.stageWidth;
		private var stageH: uint= stage.stageHeight;
		private var myRadius: uint=15;
		private var myWeight:uint = 1;
		private var myColor:uint = 0xFF00FF;
		private var xNum:uint = 32;
		private var yNum:uint =32;
		private var defX:int = 0;
		private var defY :int = 0;
		private var intervalX:int = 15;
		private var intervalY:int = 15;
		private var red:int = 0;
		private var green:int = 0;
		private var blue:int = 0;
		private var alphas:int = 0;

		
		public function CircleInteractive() {
			init();
		}
				private function init() :void{
				stage.scaleMode = StageScaleMode.NO_SCALE;
				circles = new Array();
				putCircle(xNum, yNum );
				addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
				}
		
				private function putCircle (xNum, yNum):void{
					for (var i:int = 0; i < yNum; i++ ) {
					for (var j:int = 0; j < xNum; j++ ) {
					var xPos:int = j * intervalX + defX;
					var yPos:int = i * intervalY + defY;
					myCircle = new Circle_DocClass(myRadius, myWeight, myColor, 0, 0);
													myCircle.x = xPos;
					myCircle.y = yPos;
					addChild(myCircle);
					circles.push(myCircle);
							}
					}
				}		
						
		private function onEnterFrameHandler(event:Event):void {
			for (var i:int = 0; i < circles.length; i++) {
				var circle:Circle_DocClass = circles[i];
				changeScale(circle);	
			}
		}
			
		private function changeScale (c:Circle_DocClass):void {
			var d:Number = distanceMouse(c);
			var K:Number;
			var R:Number = 22;
			var T:Number =1;
			K = R / d + T;
			if (K > 1) {
			c.scaleX = c.scaleY = K;
			}else{
			c.scaleX = c.scaleY = 1;
			}
			blue = K * 200;
			alphas = (K * 120 - 250) / 2;
			c.transform.colorTransform = new ColorTransform(1, 1, 1, 1, red, green, blue, alphas);
			}

		 private function distanceMouse(c:Circle_DocClass):Number {
			 var c:Circle_DocClass = c;
			 var mX:Number = mouseX - c.x;
			 var mY:Number = mouseY - c.y;
			 var d:Number = Math.sqrt(mX * mX + mY * mY);
			 if (d < myRadius) {
			 d = myRadius;		 
		         }
			 return d;	 
		}
	}
}

 
	import flash.display.Sprite;
	import flash.display.Shape;
	
	class Circle_DocClass extends Sprite {
		private var radius:Number;
		private var weight:Number;
		private var color:Number;
		private var posX:Number;
		private var posY:Number;
		private var pixelHinting:Boolean = false;
		private var scaleMode:String = "none";
		
		public function Circle_DocClass
			(radius:Number = 25,
			weight:Number = 15,
			color:Number = 0x335643,
			posX:Number = 275,
			posY:Number = 200) {
			this.radius = radius;
			this.weight = weight;
			this.color =color;
			this.posX =posX;
			this.posY = posY;
			init();
			
		}
		private function init():void { 
			var myCircle = new Shape();
			//myCircle.graphics.beginFill(0xFFFFFF);
			myCircle.graphics.lineStyle
			(weight, color, 1, pixelHinting, scaleMode);
			myCircle.graphics.drawCircle
			(0, 0, radius);
                        // myCircle.graphics.endFill();
			myCircle.x = posX;
			myCircle.y = posY;
			myCircle.alpha = 0.5;
			addChild(myCircle);

		}
			
	}