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

forked from: Worm Study04

Study for color generation.
// forked from fladdict's Worm Study04
// forked from fladdict's Worm Study03
// forked from fladdict's Worm Study02
// forked from fladdict's Worm Study01
// forked from fladdict's code on 2008-12-17
// write as3 code here..
// Study for color generation.
package {
  import flash.display.*
  import flash.events.*
  import flash.geom.*
  import flash.filters.BlurFilter;
  
  public class Sketch04_forked extends Sprite
  {
    public function Sketch04_forked():void {
      var bmd:BitmapData = new BitmapData( stage.stageWidth, stage.stageHeight, false, 0xffffff );
      var particles:Array = [];
      var cnt:Number = 0;
      addChild( new Bitmap(bmd) );
      for( var i: int = 0; i < 400; ++ i )
        particles.push( { 
          x: stage.stageWidth * 0.5 
          ,y: stage.stageHeight * 0.5
          ,v: 0.6 + Math.random() * 0.5
          ,direction: Math.random() * Math.PI * 2
          ,color: 0xffffff * Math.random()
          ,dv: ( Math.random() - 0.5 ) * 0.03
          ,tick: function():void {
            with( this ) 
              direction += dv += Math.random() * 0.03 - 0.015
              ,bmd.setPixel( 
                ( x += Math.cos( direction ) * v ) % stage.stageWidth
                ,( y += Math.sin( direction ) * v ) % stage.stageHeight
                ,color )
          }
        } )
      stage.addEventListener( Event.ENTER_FRAME, function( e:Event ):void {
        for( var i:String in particles ) particles[i].tick();
        ++cnt % 6 || bmd.applyFilter(bmd, bmd.rect, new Point(0, 0), new BlurFilter(2, 2, 1) );
      } )
    } // public function Sketch04_forked
  } // public class Sketch04_forked
} // package