Return to Snippet

Revision: 49466
at July 22, 2011 04:01 by zackattack27


Updated Code
package {
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	public class ExampleApplication extends Sprite{
		private var _sprite:Sprite;
				
		public function ExampleApplication(){
			_sprite = new Sprite();
			addChild(_sprite);
			_sprite.graphics.beginFill(0xFFFFFF);
			_sprite.graphics.drawRect(0, 0, 400, 400);
			_sprite.graphics.endFill();
			
			_sprite.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			_sprite.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
			
		}
		private function onMouseDown(event:MouseEvent):void{
			_sprite.graphics.lineStyle(1, 0, 1);
			_sprite.graphics.moveTo(mouseX, mouseY);
			_sprite.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		}
		private function onMouseUp(event:MouseEvent):void{
			_sprite.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		}
		private function onMouseMove(event:MouseEvent):void{
			_sprite.graphics.lineTo(mouseX, mouseY);
		}
	}
}

Revision: 49465
at July 22, 2011 04:00 by zackattack27


Initial Code
package {
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	public class ExampleApplication extends Sprite{
		private var _sprite:Sprite;
				
		public function ExampleApplication(){
			_sprite = new Sprite();
			addChild(_sprite);
			_sprite.graphics.beginFill(0xFFFFFF);
			_sprite.graphics.drawRect(0, 0, 400, 400);
			_sprite.graphics.endFill();
			
			_sprite.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			_sprite.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
			
		}
		private function onMouseDown(event:MouseEvent):void{
			_sprite.graphics.lineStyle(1, 0, 1);
			_sprite.graphics.moveTo(mouseX, mouseY);
			_sprite.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		}
		private function onMouseUp(event:MouseEvent):void{
			_sprite.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		}
		private function onMouseMove(event:MouseEvent):void{
			_sprite.graphics.lineTo(mouseX, mouseY);
		}
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
Drawing Application

Initial Tags
textmate

Initial Language
ActionScript 3