I’ve had a script in my “script tests” library for a long time now that used the noise() method of the BitmapData Class on EnterFrame to create a noisy image that somehow resembled the static when we have bad signal on TV. However it just didn’t seem complete.
Flash Player 10 came with some major improvements, one of which, is the enhancement to the Sound Class that now allows us to generate sound using actionscript alone.
Check the example below (make sure you hit the “sound” button cause i didn’t want the “hisssssS” playing by default on the blog):

[flash http://blog.locus-delicti.com/wp-content/uploads/tv_static.swf w=400 h=300]

All the source code is available below in the .fla file. But i’d like to point out online just how easy it is to generate sound in Flash 10 (5 lines!):

var hiss:Sound = new Sound();
hiss.addEventListener(SampleDataEvent.SAMPLE_DATA, hissCallbackHandler);
hiss.play();
function hissCallbackHandler(e:SampleDataEvent):void{
	for(var i:uint=0; i<2048; i++){
		//write random data in the stream
		//random float values from 0.0 to 1.0 are a perfect noise
		e.data.writeFloat(Math.random());
		e.data.writeFloat(Math.random());
	}
}

At the moment, there is an error in the LiveDocs at Adobe that confuses "SampleDataEvent" with "Event". Adobe's example won't work so just stick to the code above.

Download the source file here!