
December 1st, 2012, 09:30 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 1
Time spent in forums: 16 m 7 sec
Reputation Power: 0
|
|
Load XML into SWF Real-Time
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:
Code:
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");
Thanks
|