package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; import flash.events.Event; import flash.utils.getTimer; [SWF(width=400, height=300, backgroundColor=0x000000)] /** * Demonstrates BitmapData's noise() method by creating animated television white noise. */ public class graphic_flex_image_effects_04_Flex_NoiseTest extends Sprite { private var _bitmapData:BitmapData; /** * Constructor. Creates bitmap and handler for ENTER_FRAME for animation. */ public function graphic_flex_image_effects_04_Flex_NoiseTest() { _bitmapData = new BitmapData(stage.stageWidth, stage.stageHeight); makeNoise(); addChild(new Bitmap(_bitmapData)); addEventListener(Event.ENTER_FRAME, onSpriteEnterFrame); } /** * Generates noise in the bitmap data. */ private function makeNoise():void { _bitmapData.noise(getTimer(), 100, 255, 7, true); } /** * Generates new noise every frame. */ private function onSpriteEnterFrame(event:Event):void { makeNoise(); } } }