Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. private var flipStep:uint;
  2. private var isFlipping:Boolean = false;
  3. private var flipToFrame:uint;
  4.  
  5. // begin the flip, remember which frame to jump to
  6. public function startFlip(flipToWhichFrame:uint) {
  7. isFlipping = true;
  8. flipStep = 10;
  9. flipToFrame = flipToWhichFrame;
  10. this.addEventListener(Event.ENTER_FRAME, flip);
  11. }
  12.  
  13. // take 10 steps to flip
  14. public function flip(event:Event) {
  15. flipStep--; // next step
  16.  
  17. if (flipStep > 5) { // first half of flip
  18. this.scaleX = .20*(flipStep-6);
  19. } else { // second half of flip
  20. this.scaleX = .20*(5-flipStep);
  21. }
  22.  
  23. // when it is the middle of the flip, go to new frame
  24. if (flipStep == 5) {
  25. gotoAndStop(flipToFrame);
  26. }
  27.  
  28. // at the end of the flip, stop the animation
  29. if (flipStep == 0) {
  30. this.removeEventListener(Event.ENTER_FRAME, flip);
  31. }
  32. }
  33.  
  34. function FlipTile(e)
  35. {
  36. if (!TileFlipping)
  37. {
  38. var flipStep = 30;
  39. var sprite = e.currentTarget;
  40. console.log(sprite);
  41.  
  42. TileFlipping = true;
  43.  
  44. flipStep--;
  45.  
  46. if (flipStep > 15)
  47. {
  48. sprite.scaleX = .02 * (flipStep-6);
  49. } else {
  50. sprite.scaleX = .02 * (5 - flipStep);
  51. }
  52.  
  53.  
  54. if (flipStep == 0)
  55. {
  56. TileFlipping = false;
  57. }
  58.  
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement