Posted By

merrittwjm on 05/06/11


Tagged

parse xml load as3


Versions (?)

AS3 XML Load/Parse


 / Published in: ActionScript 3
 

  1. var xmlLoader:URLLoader = new URLLoader();
  2. var xmlData:XML = new XML();
  3. xmlLoader.addEventListener(Event.COMPLETE, onLoadXML);
  4. xmlLoader.load(new URLRequest("FST_swfStrings.xml"));
  5.  
  6. function onLoadXML(ev:Event):void{
  7. xmlData = new XML(ev.target.data);
  8. parseStrings(xmlData);
  9. //trace(xmlData)
  10. }
  11. function parseStrings(toolbarElements:XML):void{
  12. for (var i:Number = 1; i<7; i++) {
  13. var b = "btn"+i;
  14. var a = "btn"+i+"_access";
  15. btnNameArr.push(toolbarElements.string.(@name == "toolbar."+b))
  16. accessArr.push(toolbarElements.string.(@name == "toolbar."+a))
  17. }
  18. onOffArr.push(toolbarElements.string.(@name == "toolbar.btn4a"));
  19. onOffArr.push(toolbarElements.string.(@name == "toolbar.btn4b"));
  20.  
  21. //Set logo position
  22. logoX = Number(toolbarElements.string.(@name == "toolbar.logoX"));
  23. logoY = Number(toolbarElements.string.(@name == "toolbar.logoY"));
  24. mc_fstLogo.x = logoX;
  25. mc_fstLogo.y = logoY;
  26.  
  27. mc_password.str.text = btnNameArr[5];
  28. mc_setupNotComplete.str.text = btnNameArr[6];
  29.  
  30. //Dispatch custom event so Block, Settings, and Report buttons can be built
  31. dispatchEvent(new Event("xmlParsed"));
  32. }

Report this snippet  

You need to login to post a comment.