BitmapData
/**
* Copyright Mr.Star ( http://wonderfl.net/user/Mr.Star )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/gjli
*/
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.filters.BitmapFilter;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.geom.Rectangle;
import net.hires.debug.Stats;
[SWF(backgroundColor="#000000", frameRate="30", width="465", height="465")]
public class FlashTest extends Sprite {
private var bm:Bitmap;
private var filter:BitmapFilter;
private var ct:ColorTransform;
public function FlashTest() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
filter = new BlurFilter(2, 2, 1);
ct = new ColorTransform(1.012, 1.012, 1.012, 1.012);
var bmd:BitmapData = new BitmapData(465, 465, false, 0x000000);
bm = new Bitmap(bmd);
addChild(bm);
addChild(new Stats());
addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(event:Event):void
{
bm.bitmapData.applyFilter(bm.bitmapData, bm.bitmapData.rect, new Point(0, 0), filter);
bm.bitmapData.colorTransform(bm.bitmapData.rect, ct);
var rect:Rectangle = new Rectangle(Math.random()*465, Math.random()*465, 20, 20);
bm.bitmapData.fillRect(rect, Math.random()*0xFFFFFF);
}
}
}