/ Published in: ActionScript 3
simple example of startDrag and stopDrag using AS3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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(); } } }