"FOR" loop in flash to load xml data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • npm
    New Member
    • Apr 2007
    • 57

    "FOR" loop in flash to load xml data

    Hi,
    I've been using a "for" loop in a javascript to load multiple nodes from an xml file, but now I need to do the same thing in flash. Here's the javascript code:

    Code:
    xmlDoc=loadXMLDoc("xmlfile.xml");
    x=xmlDoc.getElementsByTagName('info');
    for (i=0;i<x.length;i++)
    	{
    	document.write(x[i].childNodes[0].nodeValue)
    	document.write("<br />")
    	}
    As they're written, I can't use the two variables (xmlDoc & x) or "document.write " in Actionscript. It's not working and I couldn't find anything to help me in the tutorials/help files in Flash itself. Does anyone know how to do this?

    Thanks in advance!
  • joedeene
    Contributor
    • Jul 2008
    • 579

    #2
    If you want the results of the loop to appear on the web page, or wherever you had it before, you could call the JavaScript function from Flash, let me know if you need help with that, also, If you want it to appear in the flash movie/player, then take a look at this tutorial on loops in flash. and there are plenty of tutorials on the web that you can find by searching Google. Such as this one from kirupa.com. Let me know if you need further assistance.

    joedeene

    Comment

    • npm
      New Member
      • Apr 2007
      • 57

      #3
      Thanks,
      It seems like it would be easiest to find out how to use javascript in flash, since I already have the javascript that I've been using all along. Is it easy?

      Thanks!

      Comment

      • joedeene
        Contributor
        • Jul 2008
        • 579

        #4
        In that case, the getURL function would be most suitable for your situation, and a sample JavaScript function, quoted from that site.

        In the following ActionScript, JavaScript is used to open an alert window when the SWF file is embedded in a browser window (please note that when calling JavaScript with getURL(), the url parameter is limited to 508 characters):

        Code:
        myBtn_btn.onRelease = function()
        {
         getURL("javascript:alert('you clicked me')"); 
        };
        And there are many tutorials on Google on using JavaScript with Flash, using these keywords: 'geturl flash javascript'
        (Link to Google with the keywords listed above)

        joedeene

        Comment

        Working...