Posted By

mswallace on 08/12/07


Tagged

actionscript startDrag stopDrag


Versions (?)

Who likes this?

11 people have marked this snippet as a favorite

copyleft
andrewrench
visuallyspun
ebooksrfun
THEPWN3R
themill
papillion
enajenkins
loric
tspitzr
adrianparr


ActionScript 3 Start and Stop Drag


 / Published in: ActionScript 3
 

simple example of startDrag and stopDrag using AS3

  1. package {
  2. import flash.display.Sprite;
  3. import flash.display.Shape;
  4. import flash.events.MouseEvent;
  5.  
  6.  
  7. public class DisplayList extends Sprite{
  8.  
  9. private var _rectangle:Sprite;
  10.  
  11. public function DisplayList(){
  12. _rectangle = new Sprite();
  13. _rectangle.graphics.lineStyle(0, 0xFFFFFF, 1);
  14. _rectangle.graphics.beginFill(0xFFFFFF, 1);
  15. _rectangle.graphics.drawRect(0, 0, 100, 50);
  16. addChild(_rectangle);
  17. _rectangle.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
  18. _rectangle.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
  19.  
  20.  
  21. }
  22. private function onMouseDown(event:MouseEvent):void{
  23. _rectangle.startDrag();
  24. }
  25.  
  26. private function onMouseUp(event:MouseEvent):void{
  27. _rectangle.stopDrag();
  28. }
  29.  
  30. }
  31. }

Report this snippet  

You need to login to post a comment.