Flash + XML woes

  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1893
  • Loc: Las Vegas

Post 3+ Months Ago

Hey yall, I'm having an odd problem with flash and XML.
I have vector maps that are basically just text files with x,y,z and r,g,b values that describe 2 point lines.
The text files range in size from a few K to almost 2MB.

Now, on to the problem. I have a php script that loads a map file, and spits it out as an xml file. This basically doubles the size because of the damn xml tags.

I have a flash display that pulls in the xml data and draws the map inside an empty movie clip.
I have no problem viewing the maps on my computer, but the other guy that runs the site with me says that after he loads a few maps, the maps refuse to load.
Each map uses it's own instance of the viewer, so I'm not loading xml data on top of xml data. To view a new map, the user has to go to a new webpage.

When viewing a map, the status bar of the browser shows "transferring data from http://www.mapfiend.net... the entire time.
In my flash movie, I delete the xml object after it's loaded. Why would the browser still show transferring data ? It doesn't do this on pages without the flash viewer.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1893
  • Loc: Las Vegas

Post 3+ Months Ago

Disregard. The problem is with the labels on the maps, not the map data.
Anyone have a good tutorial for adding lots of text at arbitrary locations from an xml file with actionscript?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

well ... i don't see the problem here. Either create textfields on the fly inside a movie clip or attach an already existing movieclip with a text inside.
The rest is just xml parsing.
  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1893
  • Loc: Las Vegas

Post 3+ Months Ago

well, that's what I'm doing, attaching an mc with a text field inside, but for some reason, some of the maps refuse to load. It's not a size thing, most of the ones that refuse to load are quite short. I thought there might be some unwanted "odd" characters getting in, but I don't see any.

What I'm really not getting is how a xml file with hundreds of entries will load, but one with fewer than 20 will not.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

not sure, can you provide the code used to laod the xml?
  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1893
  • Loc: Las Vegas

Post 3+ Months Ago

I'll post it when I get home on the 30th.
  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1893
  • Loc: Las Vegas

Post 3+ Months Ago

ok, here's the code I'm using. The first part is the xml parser:
Code: [ Select ]
mob_xml = new XML();
mob_xml.ignoreWhite = true;
mob_xml.onLoad = function(success) {
    if (success) {
         var startTime = getTimer();
         
         var mobs_xml = mob_xml.firstChild;
         for (var i = 0; i < mobs_xml.childNodes.length; i++) {
            var mobData = new Object();        
              for (var j = 0; j < mobs_xml.childNodes[i].childNodes.length; j++) {
                  mobData[mobs_xml.childNodes[i].childNodes[j].nodeName] = mobs_xml.childNodes[i].childNodes[j].firstChild.nodeValue;
              }
              mob_arr.push(mobData);
          }
        drawMap(map_arr, poi_arr, mob_arr);         
     } else {
         trace("Error loading mobs.");    
     }

     // clean up after ourselves
     delete mob_xml;
}
mob_xml.load( "mobxml.php?id="+_root.map_id );
  1. mob_xml = new XML();
  2. mob_xml.ignoreWhite = true;
  3. mob_xml.onLoad = function(success) {
  4.     if (success) {
  5.          var startTime = getTimer();
  6.          
  7.          var mobs_xml = mob_xml.firstChild;
  8.          for (var i = 0; i < mobs_xml.childNodes.length; i++) {
  9.             var mobData = new Object();        
  10.               for (var j = 0; j < mobs_xml.childNodes[i].childNodes.length; j++) {
  11.                   mobData[mobs_xml.childNodes[i].childNodes[j].nodeName] = mobs_xml.childNodes[i].childNodes[j].firstChild.nodeValue;
  12.               }
  13.               mob_arr.push(mobData);
  14.           }
  15.         drawMap(map_arr, poi_arr, mob_arr);         
  16.      } else {
  17.          trace("Error loading mobs.");    
  18.      }
  19.      // clean up after ourselves
  20.      delete mob_xml;
  21. }
  22. mob_xml.load( "mobxml.php?id="+_root.map_id );
It takes the incoming xml data and places it in an array called mob_arr. This part works fine, I can trace it and the data actually gets into the array.

And this part actually draws the labels on the map:
Code: [ Select ]
        for ( i = 0; i < mob_arr.length; i++ )
        {
            theMap.createTextField("moblabel"+i, i, Number(mob_arr[i].x1)+5, Number(mob_arr[i].y1), 240, 80);
            theMap["moblabel"+i].selectable = false;
            theMap["moblabel"+i].text = mob_arr[i].n;
        }
  1.         for ( i = 0; i < mob_arr.length; i++ )
  2.         {
  3.             theMap.createTextField("moblabel"+i, i, Number(mob_arr[i].x1)+5, Number(mob_arr[i].y1), 240, 80);
  4.             theMap["moblabel"+i].selectable = false;
  5.             theMap["moblabel"+i].text = mob_arr[i].n;
  6.         }
This is the part that's causing problems on some maps. It simply won't draw anything at all, no lines or labels. On the maps that cause problems, if I leave out the label data, it draws the lines fine.

This is one of the xml files that causes problems, and I can't see a dang thing wrong with it:
Code: [ Select ]
<?xml version="1.0"?>
    <m>
    <p>
        <x1>103</x1>
        <y1>71</y1>
        <n>Zeflmin Werlikanin</n>
    </p>
    <p>
        <x1>45</x1>
        <y1>-10</y1>
        <n>a guild treasurer</n>
    </p>
    <p>
        <x1>37</x1>
        <y1>4</y1>
        <n>a guild treasurer</n>
    </p>
    <p>
        <x1>-38</x1>
        <y1>4</y1>
        <n>a bank broker</n>
    </p>
    <p>
        <x1>-43</x1>
        <y1>-12</y1>
        <n>a bank broker</n>
    </p>
    <p>
        <x1>33</x1>
        <y1>22</y1>
        <n>Melody the Singer of Great Deeds</n>
    </p>
    <p>
        <x1>82</x1>
        <y1>-68</y1>
        <n>Yenny Werlikanin</n>
    </p>
    </m>
  1. <?xml version="1.0"?>
  2.     <m>
  3.     <p>
  4.         <x1>103</x1>
  5.         <y1>71</y1>
  6.         <n>Zeflmin Werlikanin</n>
  7.     </p>
  8.     <p>
  9.         <x1>45</x1>
  10.         <y1>-10</y1>
  11.         <n>a guild treasurer</n>
  12.     </p>
  13.     <p>
  14.         <x1>37</x1>
  15.         <y1>4</y1>
  16.         <n>a guild treasurer</n>
  17.     </p>
  18.     <p>
  19.         <x1>-38</x1>
  20.         <y1>4</y1>
  21.         <n>a bank broker</n>
  22.     </p>
  23.     <p>
  24.         <x1>-43</x1>
  25.         <y1>-12</y1>
  26.         <n>a bank broker</n>
  27.     </p>
  28.     <p>
  29.         <x1>33</x1>
  30.         <y1>22</y1>
  31.         <n>Melody the Singer of Great Deeds</n>
  32.     </p>
  33.     <p>
  34.         <x1>82</x1>
  35.         <y1>-68</y1>
  36.         <n>Yenny Werlikanin</n>
  37.     </p>
  38.     </m>
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

hmmm ... strange, this part works ok here, don't really know what can be the problem. I tested it and it creates all the textfields and show them.
Do you use different fonts for different maps? (though i doubt it).
A thing that i have in mind is to delete and remove all the elements from the map before loading a new map, and then try again.
Btw, try to load this map that is not working as the first map and see if it works.
  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1893
  • Loc: Las Vegas

Post 3+ Months Ago

Well, it only loads one map at a time, and if you switch maps, it actually loads a different page, so the flash movie doesn't stay loaded when they switch maps. I wonder if it might be a problem with the line data xml, like maybe it's missing a single coordinate or something. I'll look into that.

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.