flash on 2010-3-28

by hashito
♥0 | Line 49 | Modified 2010-03-28 10:57:38 | MIT License
play

ActionScript3 source code

/**
 * Copyright hashito ( http://wonderfl.net/user/hashito )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/byHx
 */

package {
	import flash.display.Sprite;
	import flash.display.*;
	import flash.events.*;
	import flash.text.TextField;
	import flash.geom.*;
	[SWF(frameRate=60,width=456,height=456)]
	public class FlashTest extends Sprite {
		public const H:Number = 456;
		public const W:Number = 456;
		public var b:Bitmap,pen:Shape,canvas:Sprite;
		public var outb:Bitmap;
		public var out:TextField=new TextField();
		public function FlashTest() {
			pen=new Shape();
			canvas=new Sprite();
			canvas.addChild(pen);
			
			b = new Bitmap(new BitmapData(W/2,H/2,false,0xffff));
			pen.graphics.beginFill(0);
			pen.graphics.drawCircle(0,0,2);
			
			outb=new Bitmap(new BitmapData(W/2,H/2,false,0xff))
			
			addChild(b);
			addChild(canvas);
			addEventListener(Event.ENTER_FRAME ,update);
			stage.addEventListener(MouseEvent.MOUSE_DOWN ,mousedown);
			stage.addEventListener(MouseEvent.MOUSE_MOVE ,mousemove);
			stage.addEventListener(MouseEvent.MOUSE_UP ,mouseup);
			
			
			out.autoSize=flash.text.TextFieldAutoSize.LEFT;
			canvas.addChild(out);
			out.text="0";
		}
		public var mousedouwn_flag:Boolean=false;
		public var color:uint=0;
		
		public function update(e:Event=null):void {
		}
		public function mousedown(e:MouseEvent=null):void {
			//var bi:BitmapData =new BitmapData(20,20,true0x000001);
			//var m:Matrix=new Matrix();
			//m.createBox(2,2)
			
			//b.bitmapData.draw(canvas,m);
			mousedouwn_flag=true;
		}
		public function mouseup(e:MouseEvent=null):void {
			mousedouwn_flag=false;
		}
		public function mousemove(e:MouseEvent=null):void {
			pen.x=mouseX;pen.y=mouseY;
			if(mousedouwn_flag){
				b.bitmapData.draw(canvas);
				//out.text="c="+color;
			}
		}
		
	}
}