A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: xml newbie, need desparate help!

  1. #1
    Junior Member
    Join Date
    Jan 2008

    xml newbie, need desparate help!

    Hi, im not new to flash but i am new to XML, today at work i was asked to simply set up a nice little flash menu, which i did, ie, 8 graphic buttons in a row all with different images on them and no dynamic text. But then the client wanted the links on the buttons to be driven from an XML sheet.

    So im asking if any one can give me a simple setup here for the XML and the AS for the flash movie to implement the XML into my movie.

    Ive been all over the net trying to find a decent tutorial or sample file that i could use but cant find a thing, so im now trying the forums to see if anyone has anything they can send or point me to.

    Any help would be gratfully appreciated.

  2. #2
    Junior Member
    Join Date
    Jun 2009
    Greater London, UK
    XML is quite straight forward, it's just a series of nodes you define yourself:

    Say you have this in a file called myXML.xml

    Each link node represents a different URL, the CDATA bit means the content of each node doesn't get parsed.

    Here's the basic AS you need:
    var xmlLoader:URLLoader = new URLLoader();  
    var XMLData:XML = new XML();
    xmlLoader.load(new URLRequest("myXML.xml")); //Loads your XML File
    xmlLoader.addEventListener(Event.COMPLETE, xmlComplete);
    function xmlComplete(e:Event):void{
    	XMLData = XML(xmlLoader.data); //Assigns the loaded XML data to your XML variable
    	myButton.addEventListener(MouseEvent.CLICK, clicked);
    function clicked(e:MouseEvent):void{
    	navigateToURL(new URLRequest(XMLData.link[2])); //www.google.ca
    It's all pretty straight forward. The main XML node (<link> is replaced with XMLData, so to reference google.com it would be XMLData.link[0]

  3. #3
    Junior Member
    Join Date
    Jan 2008
    Many thanks for you solution Kirk-Cocaine but ive managed to resolve this problem.

Posting Permissions

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

Click Here to Expand Forum to Full Width

HTML5 Development Center