2 Replies Latest reply on Dec 2, 2012 4:13 AM by wazaberry

    How can I Load Real-Time XML into SWF

    wazaberry

      Hi,

       

       

      I am a newbie and I need to load data from an XML file but the data is changed constantly. Is there a way to have the SWF refresh instead of caching the XML content at the first load.

       

       

      My current code is as following:

       

       

      var index:Number = 0;

       

      var myxml:XML = new XML();

      myxml.ignoreWhite = true;

      myxml.onLoad = function(success:Boolean):Void{

                loadData();

                setInterval(loadData, 3000);

       

      };

       

       

      function loadData(){

       

                var messages:XMLNode = myxml.firstChild;

                if(index >= messages.childNodes.length)

                          index = 0;

                var my_message:XMLNode = messages.childNodes[index];

       

       

       

                _root.status_1.htmlText = my_message.childNodes[0].firstChild.nodeValue;

       

                _root.status_2.htmlText = my_message.childNodes[1].firstChild.nodeValue;

       

                _root.status_3.htmlText = my_message.childNodes[2].firstChild.nodeValue;

       

                _root.status_4.htmlText = my_message.childNodes[3].firstChild.nodeValue;

                _root.status_5.htmlText = my_message.childNodes[4].firstChild.nodeValue;

                _root.status_6.htmlText = my_message.childNodes[5].firstChild.nodeValue;

       

       

                  index++;

       

       

      }

      myxml.load("data.xml");

       

       

       

       

      BTW: the XML is going to be on a remote site.

       

      Thanks