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: 簡単砂嵐

Get Adobe Flash player
by makc3d 10 Apr 2009
// forked from ton's 簡単砂嵐
package {
  import flash.display.*
  import flash.events.*
  import flash.media.*
  import flash.utils.*

  public class B extends Sprite {
    public var b:BitmapData = new BitmapData (465, 465);
    public var s:Sound = new Sound;

    public function B () {
      addChild (new Bitmap(b));
      addEventListener (Event.ENTER_FRAME, enterFrame);

      s.addEventListener (SampleDataEvent.SAMPLE_DATA, sampleDataHandler); 
      s.play ();
    }

    public function enterFrame (e:Event):void {
      b.noise(Math.random()*99,0,255,7,true);
    }

    public function sampleDataHandler (e:SampleDataEvent):void {
      var volume:Number = 1e-3;
      var pixels:ByteArray = b.getPixels (b.rect);
      var samples:ByteArray = new ByteArray;
      // this is not clever... someone think about something
      for (var i:int = 0; i < 8192; i++) {
        if (pixels.bytesAvailable < 2)
          pixels.position = 0;
        samples.writeFloat (pixels.readByte () * volume);
        samples.writeFloat (pixels.readByte () * volume);
      }
      e.data.writeBytes (samples);
    }
  }
}