var Cr:Array = new Array();

var Po:Array = new Array();

var sw = 1024;

var sh = 786;

var P0 = new Point(sw/2,sh/2);

var Pvx:Array = new Array();

var Pvy:Array = new Array();

var r:Array = new Array();

var angle:Array = new Array();

var l = 1200;

var rmax = 370;

for (var i = 0; i < 200; i++){ Cr[i] = new Circle(); r[i] = rmax * (0.01 + 0.99 * Math.random()); angle[i] = 2*Math.PI * Math.random(); for (var j = 0; j < i-1; j++){ if(Math.abs(r[i]-r[j])<0.05*rmax){ if(Math.abs(angle[i]*r[i]-angle[j]*r[j])<0.5*rmax*rmax/(rmax + 10*r[j])) {i--;break; } } } Po[i] = P0.add(Point.polar(r[i],angle[i])) Cr[i].x = Po[i].x; Cr[i].y = Po[i].y; Pvx[i]=0; Pvy[i]=0; var scale = 0.3 + 1.6 * Math.random()*rmax/(rmax + r[i]); Cr[i].scaleX = scale; Cr[i].scaleY = scale; addChild(Cr[i]); } addEventListener(Event.ENTER_FRAME, float); function float(e:Event):void{ for (var i = 0; i < 200; i++) { var dx:Number = mouseX - Cr[i].x; var dy:Number = mouseY - Cr[i].y; var sq:Number = Math.pow(dx, 2) + Math.pow(dy, 2); var force:Number = -50000 / (sq + 10); var dist:Number = Math.sqrt(sq); Pvx[i] += (force * dx / (0.4*dist+70)) + (Po[i].x - Cr[i].x) / 30; Pvy[i] += (force * dy / (0.4*dist+70)) + (Po[i].y - Cr[i].y) / 30; Pvx[i] *= 0.96; //play numbers to get various effects Pvy[i] *= 0.96; //play numbers to get various effects Cr[i].x += Pvx[i] / 30; Cr[i].y += Pvy[i] / 30; } } [/code] [kml_flashembed publishmethod="static" fversion="10.0.0" useexpressinstall="true" movie="http://johnbarrett.net/wp-content/uploads/2012/08/floating.swf" width="400" height="300" targetclass="flashmovie"]

[/kml_flashembed]