www.webdeveloper.com
Results 1 to 2 of 2

Thread: flash external xml into array

  1. #1
    Join Date
    Jul 2004
    Posts
    63

    flash external xml into array

    im attempting to take data in from an xml file and make it into an array in flash... below is the code im using- the problem i am having is that it dosent trace anything

    Code:
    var xmlDoc:XML = new XML(); 
    System.useCodepage = true; 
    xmlDoc.ignoreWhite = true; 
    
    xmlDoc.onLoad = function(ok:Boolean) { 
       if (ok) { 
           doMenu(this);        
       } else { 
           trace("XML did not load"); 
       } 
    }; 
    
    xmlDoc.load("myImages.xml"); 
    
    function doMenu(xml:XML) { 
       var num:Number = xml.firstChild.childNodes.length;    
       pics = new Array();    
       for (var i = 0; i < num; i++) { 
           pics[i] = xml.firstChild.childNodes[i].attributes.image;        
       } 
       trace(pics);    
    }
    here is my xml file
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> 
    
    <MENU> 
       <ITEM image="image1.jpg" /> 
       <ITEM image="image2.jpg" /> 
       <ITEM image="image3.jpg" /> 
       <ITEM image="image4.jpg" /> 
    </MENU>

  2. #2
    Join Date
    Mar 2005
    Posts
    4
    It's working wonderfully here! I guess I'll ask the obvious. Is your xml document located in the same directory as your Flash file?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles