Advertisement
Guest User

MY PC code on animate

a guest
Apr 25th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. package
  2. {
  3. import flash.display.MovieClip;
  4. import flash.events.MouseEvent;
  5. import flash.utils.Endian;
  6.  
  7. public class Presentation extends MovieClip
  8. {
  9. //declare the variables
  10. //these variables are visible to all the functions
  11. var pages:Array = new Array();
  12. var currentIndex:uint;
  13. var currentPage:MovieClip;
  14.  
  15. public function Presentation() //this is the constructor, and runs automatically
  16. {
  17. // constructor code
  18. pages[0] = new Start();
  19. pages[1] = new Slide1();
  20. pages[2] = new Slide2();
  21. pages[3] = new Slide3();
  22. pages[4] = new Slide4(); //do this to add a page
  23. pages[5] = new Slide5();
  24. pages[6] = new Slide6();
  25. pages[7] = new Slide7();
  26. pages[8] = new End();
  27.  
  28. currentIndex = 0;
  29. currentPage = pages[currentIndex];
  30. stage.addChild(currentPage);
  31.  
  32. var nav:Navigation = new Navigation();
  33. nav.y = 400;
  34. nav.alpha = 0.5;
  35. stage.addChild(nav);
  36. nav.right.addEventListener(MouseEvent.CLICK, onRightClick);
  37. nav.left.addEventListener(MouseEvent.CLICK, onLeftClick);
  38. }
  39. }
  40.  
  41. public function onRightClick(event:MouseEvent)
  42. {
  43. if(currentIndex < pages.length - 1)
  44. {
  45. currentIndex++;
  46. stage.removeChild(currentPage);
  47. currentPage = pages[currentIndex];
  48. stage.addChild(currentPage);
  49.  
  50. stage.setChildIndex(currentPage, 0);
  51. }
  52. }
  53.  
  54. public function onLeftClick(event:MouseEvent)
  55. {
  56. if(currentIndex > 0)
  57. {
  58. currentIndex--;
  59. var oldPage = currentPage;
  60. currentPage = pages[currentIndex];
  61. stage.addChild(currentPage);
  62. stage.removeChild(oldPage);
  63. stage.setChildIndex(currentPage, 0);
  64. }
  65. }
  66.  
  67. }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement