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

Pseudoblob

Pseudoblob
Get Adobe Flash player
by Kodiak 23 Apr 2011
    Embed
/**
 * Copyright Kodiak ( http://wonderfl.net/user/Kodiak )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mFuN
 */

package {
    import flash.geom.Matrix3D;
    import flash.filters.GlowFilter;
    import flash.filters.BlurFilter;
    import flash.geom.Rectangle;
    import flash.geom.Matrix;
    import flash.display.Shape;
    import flash.events.Event;
    import flash.geom.Point;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.display.Sprite;
    import caurina.transitions.Tweener;
    
    /**
    * Pseudoblobs
    **/
    public class FlashTest extends Sprite {
        
        private var m__display:Bitmap;
        private var m__data:BitmapData;        
        private var m__sprite:Shape;
        
        private var m__point1:Point;        
        private var m__point2:Point;
        
        private const BLUR:BlurFilter = new BlurFilter(40, 40, 3);
        private const GLOW:GlowFilter = new GlowFilter(0, 1, 20, 20);
        private const MAXDISTANCE:uint = 80;
        
        public function FlashTest() {
            // write as3 code here..
            m__point1 = new Point(100 + Math.random()*MAXDISTANCE, 100 + Math.random()*MAXDISTANCE);
            m__point2 = new Point(100 + Math.random()*MAXDISTANCE, 100 + Math.random()*MAXDISTANCE);
            
           m__sprite  = new Shape();
           m__sprite.graphics.beginFill(0);
           m__sprite.graphics.drawCircle(0, 0, 20);
           
           m__display = new Bitmap();
           addChild(m__display);
           
           movePoints();
            
           addEventListener(Event.ENTER_FRAME, onEnterFrame);
            
        }
        
        private function movePoints():void
        {
            var l__time:Number=Math.random()+.1;
            var l__x:uint =Math.random()*(stage.stageWidth-MAXDISTANCE*2)+MAXDISTANCE;
            var l__y:uint =Math.random()*(stage.stageHeight-MAXDISTANCE*2)+MAXDISTANCE;
            Tweener.addTween(m__point1, {x:l__x + Math.random()*MAXDISTANCE, y:l__y + Math.random()*MAXDISTANCE, time:l__time, transition:"easeInOutExpo"});
            Tweener.addTween(m__point2, {x:l__x + Math.random()*MAXDISTANCE, y:l__y + Math.random()*MAXDISTANCE, time:l__time, transition:"easeInOutExpo", onComplete:movePoints});
        }

        
        private function onEnterFrame(event:Event):void
        {
            m__data = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xFFFFFF);
            var l__matrix:Matrix = new Matrix();
            l__matrix.translate(m__point1.x, m__point1.y);
            m__data.draw(m__sprite, l__matrix);
            
            l__matrix = new Matrix();
            l__matrix.translate(m__point2.x, m__point2.y);
            m__data.draw(m__sprite, l__matrix);
            
            m__data.applyFilter(m__data, new Rectangle(0, 0, m__data.width, m__data.height), new Point(), BLUR);
            m__data.threshold(m__data, new Rectangle(0, 0, m__data.width, m__data.height), new Point(), "<", 0xFFEEEEEE);
            
            m__display.bitmapData = m__data;
        }

    }
}