Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. cannonball1.buttonMode = true; // sets mouse pointer to hand
  2. cannonball2.buttonMode = true;
  3. cannonball3.buttonMode = true;
  4.  
  5. cannonball1.addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
  6. cannonball1.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
  7. cannonball2.addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
  8. cannonball2.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
  9. cannonball3.addEventListener(MouseEvent.MOUSE_DOWN, clickToDrag);
  10. cannonball3.addEventListener(MouseEvent.MOUSE_UP, releaseToDrop);
  11.  
  12. function clickToDrag(event:MouseEvent):void {
  13. event.target.StartDrag();
  14. }
  15.  
  16. function releaseToDrop(event:MouseEvent):void {
  17. var thisItem:Object = event.target;
  18.    if(thisItem.hitTestObject(targetShip) {
  19.      gotoAndStop(FRAME_NUM)
  20.     
  21.     } else {
  22.       thisItem.visible = false;
  23.      }
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement