A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: xml not loading completely

  1. #1
    Member
    Join Date
    May 2002
    Posts
    42

    xml not loading completely

    Hi,
    I have a relatively small actionscript that colors the states on a map based on xml data. It worked fine for a long time, but I just added a lot of data. With the new data, the xml file is a lot bigger; and the states stop getting colored around Utah. It seems to be processing the map before it has finished processing the xml file. To check, I removed all of the Texas data and Utah then displayed correctly.
    Thanks for any help,
    Debbie

    Actionscript Code:
    var dp = new Array();
    dp_xml = new XML();
    dp_xml.ignoreWhite = true;
    dp_xml.load('dplaws.xml'#;
    dp_xml#onLoad = function#sucess# {
            if #sucess# {
                    parseFile#dp_xml#;
                    showArray##;
            }
    };



    function Map#state, category, qid, question, response# {
            this#state = state;
            this#category = category;
            this#qid = qid;
            this#question = question;
            this#response = response;

            if##substring#response,1,3#=="Yes"# && #qid == "b"## {
                myColor = new Color#state#;
                myColor#setRGB#0xA2B5CD#;
            } else if##substring#response,1,3#!="Yes"# && #qid == "b"## {
                myColor = new Color#state#;
                myColor#setRGB#0xcccccc#;
            }
    }


    function parseFile#xmlDoc_xml# {
            temp = new Array##;
            for #var a = 0; a<xmlDoc_xml#firstChild#childNodes#length; a++# {
                    for #var b = 0; b<xmlDoc_xml#firstChild#firstChild#childNodes#length; b++# {
                            temp#b# = xmlDoc_xml#firstChild#childNodes#a##childNodes#b##firstChild#nodeValue;
                    }
                    n = new Map#temp#0#, temp#1#, temp#2#, temp#3#, temp#4##;
                    dp#push#n#;
            }
    }


    function showArray##{
    for #var z = 0; z<dp.length; z++# {
            trace#dp[z].state#;
            trace#dp[z].category#;
            trace#dp[z].question#;
            trace#dp[z].response#;
            trace#dp[z].qid#;
    }
    }

  2. #2
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    760
    AS2 is pretty forgiving language and xml is not native to it so it does like what browsers do and loads as best as can be interpreted. My guess is that your xml is malformed. Try opening your xml in an editor or even IE to make sure it is structured correctly. This will show you if there is an issue.


    Oxygen has a good free one.
    Last edited by rynoe; 03-25-2013 at 03:12 PM.
    [SIGPIC][/SIGPIC]

  3. #3
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    I don't think your code is in proper AS syntax..


    try this:

    PHP Code:
    var dp = new Array();
    dp_xml = new XML();
    dp_xml.ignoreWhite true;

    dp_xml.onLoad = function(sucess) {
        if (
    sucess) {
            
    parseFile(dp_xml);
            
    showArray();
        }
    };

    dp_xml.load('dplaws.xml');

    function 
    Map(statecategoryqidquestionresponse) {
        
    this.state state;
        
    this.category category;
        
    this.qid qid;
        
    this.question question;
        
    this.response response;

        if ((
    substring(response13) == "Yes" && qid == "b")) {
            
    myColor = new Color(state);
            
    myColor.setRGB(0xA2B5CD);
        } else if ((
    substring(response13) != "Yes" && qid == "b")) {
            
    myColor = new Color(state);
            
    myColor.setRGB(0xcccccc);
        }
    }


    function 
    parseFile(xmlDoc_xml) {
        
    temp = new Array();
        for (var 
    0a<xmlDoc_xml.firstChild.childNodes.lengtha++) {
            for (var 
    0b<xmlDoc_xml.firstChild.firstChild.childNodes.lengthb++) {
                
    temp[b] = xmlDoc_xml.firstChild.childNodes[a].childNodes[b].firstChild.nodeValue;
            }
            
    = new Map(temp[0], temp[1], temp[2], temp[3], temp[4]);
            
    dp.push(n);
        }
    }


    function 
    showArray() {
        for (var 
    0z<dp.lengthz++) {
            
    trace(dp[z].state);
            
    trace(dp[z].category);
            
    trace(dp[z].question);
            
    trace(dp[z].response);
            
    trace(dp[z].qid);
        }

    hope this help


    arkitx
    Last edited by arkitx; 03-25-2013 at 04:34 PM.

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    It was fixed over at AS,org, it was indeed a malformed xml file.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center