package {
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
public class Main extends Sprite {
private var _bitmap:BitmapData= new BitmapData(stage.stageWidth,stage.stageHeight,false, 0xffffffff);
public function Main ( ) {
var sprite:Sprite = new Sprite( );
addChild(sprite);
for(var i:int = 0; i < 200; i++) {
_bitmap.fillRect(new Rectangle(
Math.random( ) * stage.stageWidth,
Math.random( ) * stage.stageHeight,
20, 20), Math.random( ) * 0xffffffff);
}
var image:Bitmap = new Bitmap(_bitmap);
sprite.addChild(image);
sprite.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
}
public function onMouseDown(event:MouseEvent):void {
_bitmap.floodFill(mouseX, mouseY, 0xffff0000);
}
}
}
|