Guest User

Untitled

a guest
Oct 3rd, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import be.ikdoeict.ConnectPHP;
  4.     import be.ikdoeict.CustomEvent;
  5.     import be.ikdoeict.ParseXML;
  6.    
  7.     import flash.display.Sprite;
  8.     import flash.display.StageAlign;
  9.     import flash.display.StageScaleMode;
  10.     import flash.events.Event;
  11.     import flash.events.MouseEvent;
  12.     import flash.net.URLLoader;
  13.     import flash.net.URLRequest;
  14.     import flash.xml.XMLDocument;
  15.    
  16.     public class Main extends Sprite
  17.     {
  18.         private const XMLFILE:String = "./xml/pages.xml";
  19.         private var pictureBook:BookMc;
  20.         public static var rootMc:Sprite;
  21.         private var page:Sprite;
  22.         private var pageMc:PageMc;
  23.        
  24.         public function Main()
  25.         {
  26.             if (stage) init();
  27.             else addEventListener(Event.ADDED_TO_STAGE, init);
  28.  
  29.         }
  30.        
  31.         public function init(e:Event = null):void {
  32.             if (e != null) removeEventListener(Event.ADDED_TO_STAGE, init);
  33.            
  34.             // Basisinstellingen van de stage en rootMc
  35.             stage.scaleMode = StageScaleMode.NO_SCALE;
  36.             stage.align = StageAlign.TOP_LEFT;
  37.             rootMc = new Sprite();
  38.            
  39.             this.addChild(rootMc);
  40.  
  41.             pictureBook = new BookMc();
  42.             pictureBook.x = 700;
  43.             pictureBook.y = 20;
  44.             rootMc.addChild(pictureBook);
  45.            
  46.  
  47.             pictureBook.mainPage.buttonNext.addEventListener(MouseEvent.CLICK, nextHandler);
  48.            
  49.         }
  50.        
  51.         private function nextHandler(e:MouseEvent):void {
  52.             rootMc.removeChild(pictureBook);
  53.             var parseXml:ParseXML = new ParseXML(XMLFILE, addContent);
  54.             rootMc.addChild(pageMc);
  55.         }
  56.        
  57.         private function addContent(pagesArr:Array):void {
  58.             page = new Sprite();
  59.             for (var i:int = 0; i < pagesArr.length; i++) {
  60.                 var pageContent:Page = new Page(pagesArr[i][0], pagesArr[i][1]);
  61.                 pageContent.x = 50 * i;
  62.                 page.addChild(pageContent);
  63.             }
  64.             pageMc.addChild(page);
  65.  
  66.            
  67.         }
  68.        
  69.     //  public function prevHandler(e:MouseEvent):void {
  70.     //      book.removeChild(pages[0]);
  71.     //      book.addChild(book.mainPage);
  72.     //      book.mainPage.x = 700;
  73.     //      book.mainPage.y = 20;
  74.     //  }
  75.        
  76.     //  public function getPages():void {
  77.            
  78.     //  }
  79.     }
  80. }
Add Comment
Please, Sign In to add comment