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

引力・斥力2

Get Adobe Flash player
by cpu_t 20 Jun 2010
    Embed
/**
 * Copyright cpu_t ( http://wonderfl.net/user/cpu_t )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qNfN
 */

package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.events.Event;
    public class FlashTest extends Sprite
    {
        public function FlashTest()
        {
        		graphics.beginFill(0);
        		graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
        		stage.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
         	nodelist=new Array();
         	addEventListener(Event.ENTER_FRAME,enterFrameHandler);
        }
        private var nodelist:Array;
        private function mouseDownHandler(e:MouseEvent):void
        {
        		var node:Node=new Node();
        		addChild(node);
        		node.x=mouseX;
        		node.y=mouseY;
        		nodelist.push(node);
        		nodedis+=2;
        }
        private var nodedis:Number=30;
        private function enterFrameHandler(e:Event):void
        {
        		var node:Node;
        		for each(node in nodelist)
        		{
        			node.vx*=0.7;node.vy*=0.7;
        			node.vx+=(mouseX-node.x)*0.01;
        			node.vy+=(mouseY-node.y)*0.01;
        			for each(var node2:Node in nodelist)
        			{
        				if(node==node2)continue;
        				var dis:Number=Math.sqrt((node2.x-node.x)*(node2.x-node.x)+(node2.y-node.y)*(node2.y-node.y));
        				node.vx+=(node2.x-node.x)/dis*(dis-nodedis)*0.01;
        				node.vy+=(node2.y-node.y)/dis*(dis-nodedis)*0.01;
        			}
        		}
        		for each(node in nodelist)
        		{
        			node.x+=node.vx;node.y+=node.vy;
        		}
        }
    }
}

import flash.display.Sprite;
import flash.filters.BlurFilter;
class Node extends Sprite
{
	public function Node()
	{
        graphics.beginFill(Math.random()*0xFFFFFF);
        graphics.drawCircle(0,0,10);
	}
	private static var bFilter:BlurFilter=new BlurFilter();
	public var vx:Number=0;
	public var vy:Number=0;
}