ulfben

Sample Config XML load & parse

Apr 30th, 2013
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* SNIP */
  2. var configLoader:URLLoader = new URLLoader(new URLRequest("data/config.xml"));
  3. configLoader.addEventListener("complete", configLoaded, false, 0, true);
  4. /* SNIP */
  5.  
  6. private function configLoaded(e:Event):void {
  7.             var loader:URLLoader = e.target as URLLoader;
  8.             var configXML:XML;
  9.             try {
  10.                 configXML = new XML(loader.data);
  11.             }catch (e:TypeError) {
  12.                 trace("ERROR: could not parse the XML file.");
  13.                 return;
  14.             }
  15.             Conf._playerScale = configXML.playerScale.@value;
  16.             Conf._walkRate = configXML.walkRate.@value;
  17.             Conf._targetBuffer = configXML.targetBuffer.@value;
  18.             Conf._playerName = configXML.playerName.@value;        
  19.             Conf._musicURL = configXML.musicURL.@value;
  20.             Conf._endMusicURL = configXML.endMusicURL.@value;
  21.             Conf._mouseEdge = configXML.mouseEdge.@value;
  22.             Conf._scrollTime = configXML.scrollTime.@value;
  23.             Conf._captionsOn = configXML.captionsOn.@value as Boolean;         
  24.             Conf._scenePath = configXML.scenesPath.@value;
  25.             var firstLocation:String = configXML.firstScene.@value;        
  26.             createNewScene(firstLocation)
  27.             _currentScene.addEventListener(Event.COMPLETE, maybeStartGame, false, 0, true);
  28.         }
RAW Paste Data