Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.MovieClip;
- import flash.events.MouseEvent;
- import flash.utils.Endian;
- public class Presentation extends MovieClip
- {
- //declare the variables
- //these variables are visible to all the functions
- var pages:Array = new Array();
- var currentIndex:uint;
- var currentPage:MovieClip;
- public function Presentation() //this is the constructor, and runs automatically
- {
- // constructor code
- pages[0] = new Start();
- pages[1] = new Slide1();
- pages[2] = new Slide2();
- pages[3] = new Slide3();
- pages[4] = new Slide4(); //do this to add a page
- pages[5] = new Slide5();
- pages[6] = new Slide6();
- pages[7] = new Slide7();
- pages[8] = new End();
- currentIndex = 0;
- currentPage = pages[currentIndex];
- stage.addChild(currentPage);
- var nav:Navigation = new Navigation();
- nav.y = 400;
- nav.alpha = 0.5;
- stage.addChild(nav);
- nav.right.addEventListener(MouseEvent.CLICK, onRightClick);
- nav.left.addEventListener(MouseEvent.CLICK, onLeftClick);
- }
- }
- public function onRightClick(event:MouseEvent)
- {
- if(currentIndex < pages.length - 1)
- {
- currentIndex++;
- stage.removeChild(currentPage);
- currentPage = pages[currentIndex];
- stage.addChild(currentPage);
- stage.setChildIndex(currentPage, 0);
- }
- }
- public function onLeftClick(event:MouseEvent)
- {
- if(currentIndex > 0)
- {
- currentIndex--;
- var oldPage = currentPage;
- currentPage = pages[currentIndex];
- stage.addChild(currentPage);
- stage.removeChild(oldPage);
- stage.setChildIndex(currentPage, 0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement