Ask a Question related to Macromedia Flash Data Integration, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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() ."/";...
    4. 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...
    5. 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...
  3. #2

    Default 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

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139