Return to Snippet

Revision: 3553
at August 12, 2007 08:10 by mswallace


Initial Code
package {
	import flash.display.Sprite;
	import flash.display.Shape;
	import flash.events.MouseEvent;
	
	
	public class DisplayList extends Sprite{
		
		private var _rectangle:Sprite;
			
		public function DisplayList(){
			_rectangle = new Sprite();
			_rectangle.graphics.lineStyle(0, 0xFFFFFF, 1);
			_rectangle.graphics.beginFill(0xFFFFFF, 1);
			_rectangle.graphics.drawRect(0, 0, 100, 50);
			addChild(_rectangle);
			_rectangle.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
			_rectangle.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
			
			
		}
		private function onMouseDown(event:MouseEvent):void{
			_rectangle.startDrag();
		}
		
		private function onMouseUp(event:MouseEvent):void{
			_rectangle.stopDrag();
		}
		
	}
}

Initial URL


Initial Description
simple example of startDrag and stopDrag using AS3

Initial Title
ActionScript 3 Start and Stop Drag

Initial Tags
actionscript

Initial Language
ActionScript 3