forked from: forked from: code on 2009-1-13
// forked from wannabe's forked from: code on 2009-1-13
// forked from 28houuse's code on 2009-1-13
// write as3 code here..
package
{
import flash.display.Stage;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.filters.BlurFilter;
import flash.utils.getTimer;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.events.Event;
public class Blobs extends Sprite
{
private var bl : Array = [];
private var r : Bitmap;
private var c : Sprite;
private var rect : Rectangle;
private var point : Point = new Point;
public function Blobs()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init( e : Event ) : void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.align = "TL";
stage.scaleMode = "noScale";
c = new Sprite();
c.filters = [new BlurFilter(20,20,10)];
addChild(c);
r = new Bitmap( new BitmapData( stage.stageWidth, stage.stageHeight, false, 0x00FFFFFF ) );
addChild(r);
for (var i:Number = 0; i < 10; i ++)
{
bl[i] = new MovieClip();
bl[i].graphics.beginGradientFill("radial",[0xFF0000, 0xFF0000],[100,100],[0, 0xFF]);
bl[i].graphics.drawCircle(0,0,Math.random()*20+15);
//bl[i].x = Math.random() * stage.stageWidth;
//bl[i].y = Math.random() * stage.stageHeight;
bl[i].x = 200;
bl[i].y = 200;
bl[i].cycle = Math.random() * 100000;
c.addChild(bl[i]);
}
for (var j:Number = 10; j < 20; j ++)
{
bl[j] = new MovieClip();
bl[j].graphics.beginGradientFill("linear",[0x0000FF,0x0000FF],[100,0100],[0,0xFF]);
bl[j].graphics.drawCircle(0,0,Math.random()*20+25);
//bl[i].x = Math.random() * stage.stageWidth;
//bl[i].y = Math.random() * stage.stageHeight;
bl[j].x = 300;
bl[j].y = 300;
bl[j].cycle = Math.random() * 100000;
c.addChild(bl[j]);
}
rect = new Rectangle(0,0,stage.stageWidth, stage.stageHeight);
addEventListener( Event.ENTER_FRAME, u );
}
public function u(e : Event) : void
{
for (var i:Number = 0; i < 20; i ++)
{
bl[i].x += Math.sin( ( getTimer() + bl[i].cycle ) * .002 ) * 2;
bl[i].y += Math.cos( ( getTimer() + bl[i].cycle ) * .002 ) * 2;
bl[i].scaleX = bl[i].scaleY += Math.sin( ( getTimer() + bl[i].cycle ) *.0001 ) *.00015 ;
}
r.bitmapData.fillRect(rect,0x00FFFFFF);
r.bitmapData.draw(c);
r.bitmapData.threshold(r.bitmapData,rect,point,">",0x00800000,0xFFFFFFFF,0x00808080,true);
}
}
}