code on 2009-1-13
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.ConvolutionFilter;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.utils.getTimer;
[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="24")]
public class Noise001 extends MovieClip
{
private var bmp:Bitmap;
private var i:int;
public function Noise001()
{
addEventListener(Event.ADDED_TO_STAGE, addedToStage);
}
private function addedToStage(e:Event):void
{
removeEventListener(e.type, arguments.callee);
bmp = new Bitmap(new BitmapData(stage.stageWidth, stage.stageHeight, false, 0) );
bmp.bitmapData.noise( getTimer(), 0, 8, 7, true );
addChild(bmp);
addEventListener(Event.ENTER_FRAME, enterFrame);
}
private function enterFrame(e:Event):void
{
if (i % 1000 == 0) {
bmp.bitmapData.noise( getTimer(), 0, 8, 7, true );
}else {
bmp.bitmapData.applyFilter(
bmp.bitmapData,
new Rectangle(0, 0, 465, 465),
new Point(),
new ConvolutionFilter( 3, 3,
[ 3, 3, 3, 3, 2, 3, 3, 3, 3],
255, 0, true, false, 0, 1));
}
bmp.bitmapData.threshold(
bmp.bitmapData,
bmp.bitmapData.rect,
new Point(),
"==", 8, 0xFFFFFFFF, 0xFC);
i++;
}
}
}