Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //============
  2. //  LESSON 1
  3. //============
  4.  
  5. //This line simply adds an event listener for the "Main Menu" button
  6. //by calling the function defined on the previous frame. As this will
  7. //be used in every frame from now on, it will not be mentioned again.
  8.  
  9. mainmenuInstance.addEventListener(MouseEvent.CLICK, returnToMenu);
  10.  
  11. // ==================================================================
  12.  
  13. var node1:Number = 0
  14. //var node1Value:String = node1.toString();
  15. //currentNodeLesson1.text = node1.toString();
  16.  
  17. nextPhrase.addEventListener(MouseEvent.CLICK, nextNode);
  18.  
  19. function nextNode(event:MouseEvent):void
  20. {
  21.     trace("NEXT");
  22.     node1++;
  23.     trace(node1);
  24.     ParseData(xmlDataLesson1);
  25. }
  26.  
  27. var xmlLoaderLesson1:URLLoader = new URLLoader();
  28. var xmlDataLesson1:XML = new XML();
  29.  
  30. xmlLoaderLesson1.addEventListener(Event.COMPLETE, lesson1XML);
  31.  
  32. xmlLoaderLesson1.load(new URLRequest("lesson1.xml"));
  33.  
  34. XML.ignoreWhitespace = false;
  35.  
  36. function lesson1XML(e:Event):void
  37. {
  38.     xmlDataLesson1 = new XML(e.target.data);
  39. }
  40.  
  41.  
  42. function ParseData(dataInput:XML):void
  43. {
  44.     trace("XML Output");
  45.     trace("------------------------");
  46.     trace(dataInput.phrase.norwegian.text()[node1]);
  47.    
  48.     lesson1Norwegian.text = dataInput.phrase.norwegian.text()[node1];
  49.     //currentNodeLesson1.text = node1;
  50.     //dataInput refers to the whole XML
  51.     //phrase returns all <phrase> tags' contents
  52.     //norwegian returns only <norwegian> tags within those
  53.     //text() removes the tags when tracing
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement