topical media & game development
#graphic-flex-image-effects-04-Flex-NoiseTest.ax
#graphic-flex-image-effects-04-Flex-NoiseTest.ax
[swf]
[flash]
flex
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 @ax-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 @ax-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();
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.