. MouseEvent ; import flash. events. MouseEvent;
. BitmapData ; import flash. display. BitmapData;
. Bitmap ; import flash. display. Bitmap;
. GradientType ; import flash. display. GradientType;
/ /
. Matrix ; import flash. Geom. Matrix;
/ /
= false ; var md: Boolean = false;
/ /
Sprite ( ) ; var event_spr: Sprite = new Sprite ();
; addChild (event_spr);
/ /
= event_spr. stage . stageWidth ; var area_width: Number = event_spr. stage. stageWidth;
= event_spr. stage . stageHeight - 32 ; var area_height: Number = event_spr. stage. stageHeight - 32;
/ /
= GradientType. LINEAR ; var fillType: String = GradientType. LINEAR;
= [ 0xFF0000, 0x00FF00, 0x0000ff ] ; var colors: Array = [0xFF0000, 0x00FF00, 0x0000ff];
= [ 1 , 1 , 1 ] ; var alphas: Array = [1, 1, 1];
= [ 0 , 128 , 255 ] ; var ratios: Array = [0, 128, 255];
= SpreadMethod. PAD ; var spreadMethod: String = SpreadMethod. PAD;
Matrix ( ) ; var matrix: Matrix = new Matrix ();
area_width, area_height, 1 , 0 , 0 ) ; matrix. createGradientBox (area_width, area_height, 1, 0, 0);
/ /
event_spr. graphics ) { with (event_spr. graphics) (
fillType,colors,alphas,ratios,matrix,spreadMethod ) ; beginGradientFill (fillType, colors, alphas, ratios, matrix, spreadMethod);
, 0 ,area_width, area_height ) ; drawRect (0, 0, area_width, area_height);
; endFill ();
)
/ / Paint event
MouseEvent. MOUSE_DOWN , _onMouseDown ) ; event_spr. addEventListener (MouseEvent. MOUSE_DOWN, _onMouseDown);
MouseEvent. MOUSE_MOVE , _onMouseMove ) ; event_spr. addEventListener (MouseEvent. MOUSE_MOVE, _onMouseMove);
MouseEvent. MOUSE_UP , _onMouseUp ) ; event_spr. addEventListener (MouseEvent. MOUSE_UP, _onMouseUp);
MouseEvent. MOUSE_OUT , _onMouseUp ) ; event_spr. addEventListener (MouseEvent. MOUSE_OUT, _onMouseUp);
/ /
BitmapData ( event_spr. width ,event_spr. height , true , 0 ) ; var bmpd: BitmapData = new BitmapData (event_spr. width, event_spr. height, true, 0);
Bitmap ( bmpd ) ; var bmp: = new Bitmap Bitmap (bmpd);
; addChild (bmp);
/ /
/ / Temporary shape
Shape ( ) ; var draw_shape: Shape = new Shape ();
; addChild (draw_shape);
/ /
/ / Shape, not visible, used for the "abolition"
Shape ( ) ; var erase_shape: Shape = new Shape ();
/ /
e :MouseEvent ) : void { _onMouseDown function (e: MouseEvent): void (
) ; debug ( "_onMouseDown");
( 10 , 0xffffff, 1 ) ; draw_shape. graphics. LineStyle (10, 0xffffff, 1);
( 20 , 0xffffff, 1 ) ; erase_shape. graphics. LineStyle (20, 0xffffff, 1);
( e . localX , e . localY ) ; draw_shape. graphics. moveTo (e. localX, and. localY);
( e . localX , e . localY ) ; erase_shape. graphics. moveTo (e. localX, and. localY);
md = true;
)
/ /
e :MouseEvent ) : void { _onMouseUp function (e: MouseEvent): void (
md = false;
( draw_shape ) ; bmp. BitmapData. draw (draw_shape);
( ) ; draw_shape. graphics. clear ();
( ) ; erase_shape. graphics. clear ();
)
/ /
e :MouseEvent ) : void { _onMouseMove function (e: MouseEvent): void (
) ; debug ( "_onMouseMove");
md && ! e . ctrlKey ) { if (md & &! and. ctrlKey) (
( e . localX , e . localY ) ; draw_shape. graphics. lineTo (e. localX, and. localY);
( md && e . ctrlKey ) { ) Else if (e & & md. CtrlKey) (
( e . localX , e . localY ) ; erase_shape. graphics. lineTo (e. localX, and. localY);
( erase_shape, null , null , "erase" ) ; bmp. BitmapData. draw (erase_shape, null, null, "erase");
)
)
/ /
v: String ) : void { debug function (v: String): void (
= new Date ( ) ; var d: Date = new Date ();
d. getMinutes ( ) + ":" +d. getSeconds ( ) + ":" +d. getMilliseconds ( ) + ": " +v ) ; trace (d. getMinutes () + ":" + d. getSeconds () + ":" + d. getMilliseconds () + ":" + v);
)