Ask a Question related to Macromedia Flash Data Integration, Design and Development.
-
airkado #1
Reading XML
Hi, i have an xml file, which i have to read. I know how to read it once, but i
have to read it all the time, because it reads some numbers, which are changing
and managing my events.
The XML file looks like this:
<?xml version="1.0" encoding="utf-8" ?>
- <hotspots>
<sequence>47</sequence>
<hotspot id="1">0</hotspot>
<hotspot id="2">0</hotspot>
<hotspot id="3">0</hotspot>
<hotspot id="4">0</hotspot>
<hotspot id="5">0</hotspot>
<hotspot id="6">0</hotspot>
<hotspot id="7">0</hotspot>
<hotspot id="8">0</hotspot>
<hotspot id="9">0</hotspot>
</hotspots>
I have to read if hotspot has value 1 or 0. I have to read only hotspots, with
id=1,id=2 and id=3.If the number changes, then something happens in my flash
file.
My current code:
var mojXML:XML = new XML();
mojXML.ignoreWhite = true;
var output:String = "";
mojXML.onLoad = function(success){
if(success)
{
var tabela:Array = mojXML.firstChild.childNodes;
//ce je prvi ena
if(tabela[1].childNodes[0].nodeValue == 1){
if(tabela[2].childNodes[0].nodeValue == 0){
if(tabela[3].childNodes[0].nodeValue == 0){
trace("zazeni prvega");
}else{trace("zazeni tretjega");}
}
else if(tabela[2].childNodes[0].nodeValue == 1){
if(tabela[3].childNodes[0].nodeValue == 0){
trace("zazeni drugega");
}else{trace("zazeni tretjega");}
}
}
//ce je prvi 0
else if(tabela[1].childNodes[0].nodeValue == 0){
if(tabela[2].childNodes[0].nodeValue == 0){
if(tabela[3].childNodes[0].nodeValue == 0){
trace("zazeni prvega, ki je default");
}else{trace("zazeni tretjega");}
}
else if(tabela[2].childNodes[0].nodeValue == 1){
if(tabela[3].childNodes[0].nodeValue == 0){
trace("zazeni drugega");
}else{trace("zazeni tretjega");}
}
}
else{
trace("first as default");
}
}
else{
trace("XML ni OK");
}
}
mojXML.load("hotspot_processed.xml");
It is probably a simple solution, so i hope that someone can help me.
mojXML.onLoad = function(success){
if(success)
{
var tabela:Array = mojXML.firstChild.childNodes;
//ce je prvi ena
if(tabela[1].childNodes[0].nodeValue == 1){
if(tabela[2].childNodes[0].nodeValue == 0){
if(tabela[3].childNodes[0].nodeValue == 0){
trace("zazeni prvega");
}else{trace("zazeni tretjega");}
}
else if(tabela[2].childNodes[0].nodeValue == 1){
if(tabela[3].childNodes[0].nodeValue == 0){
trace("zazeni drugega");
}else{trace("zazeni tretjega");}
}
}
//ce je prvi 0
else if(tabela[1].childNodes[0].nodeValue == 0){
if(tabela[2].childNodes[0].nodeValue == 0){
if(tabela[3].childNodes[0].nodeValue == 0){
trace("zazeni prvega, ki je default");
}else{trace("zazeni tretjega");}
}
else if(tabela[2].childNodes[0].nodeValue == 1){
if(tabela[3].childNodes[0].nodeValue == 0){
trace("zazeni drugega");
}else{trace("zazeni tretjega");}
}
}
else{
trace("first as default");
}
}
else{
trace("XML ni OK");
}
}
mojXML.load("hotspot_processed.xml");
airkado Guest
-
reading .htm as .cfm
Revisiting 1999 solution to pass embedded code in .htm pages thru the CF Server. I just posted this same query to the CFUG group. We were using... -
Reading from log
Hello all, I am looking for help with creating a digest of a log file. I have found a nice tutorial that should help on... -
dir reading
Can any one tell me why when i have the current dir have 6 jpg files and the index.php i use this code $cnt = 1; $dir = getcwd() ."/";... -
Reading in CDs
I have made a director movie with some quicktime movies. All worked well on the computers then I try to transfer the files to a CD. However, when I... -
RDF reading in .NET
How do you read RDF links (like news feeds) in .NET I was using XML reader but am getting invalid format now, since going to 1.1 of the... -
theTraveler3 #2
Re: Reading XML
If you need to constantly update and read the XML file I can think of 2 easy
solutions.
1. Create a time out, and just keep reloading that file ever n seconds (or
whatever is appropriate). This is like the AJAX approach. From a
synchronization perspective, you'll want a flag to indicate whether the
previous load has finished too, that way your XML object only loads 1 thing at
a time. The drawback is that your often pulling data from the server that
isn't new.
2. Use the XMLSocket Object, which opens a persistent-2-way socket connection
to your server. An event will be thrown whenever new data is sent through the
socket notifying your Flash doc to reparse. The drawback here is that you need
to setup a SocketServer somewhere... I havn't writen a Flash Socket Server in a
while, but last time I did it in Java or C.
Hope this helps out.
theTraveler3 Guest



Reply With Quote

