Chapter 36 Example 8
♥0 |
Line 21 |
Modified 2010-02-09 14:33:33 |
MIT License
archived:2017-03-20 03:52:18
ActionScript3 source code
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/c4dJ
*/
package {
import flash.display.*;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
public class ch36ex8 extends Sprite {
protected var bmp:BitmapData;
public function ch36ex8() {
bmp = new BitmapData(200, 200, false);
bmp.fillRect(new Rectangle(0, 0, 100, 100), 0xffff0000);
bmp.fillRect(new Rectangle(100, 0, 100, 100), 0xff00ff00);
bmp.fillRect(new Rectangle(0, 100, 100, 100), 0xff0000ff);
bmp.fillRect(new Rectangle(100, 100, 100, 100), 0xffffff00);
var bitmap:Bitmap = new Bitmap(bmp);
addChild(bitmap);
stage.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(event:MouseEvent):void {
bmp.floodFill(event.localX, event.localY, Math.random() * 0xffffff);
}
}
}