dcsimg
A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: Loading xml into an array

  1. #1
    Senior Member
    Join Date
    May 2005
    Location
    Wisconsin
    Posts
    181

    Loading xml into an array

    Im confused why after my 2nd loop interval my traces come up undefined. What am I missing here? Everythign apears perfect the first two loops.
    Code:
    stop();
    qst = new Array([]);
    ans = new Array([], []);
    val = new Array([], []);
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("stc1062.xml");
    var questionXML:Array = new Array();
    function loadXML(loaded) {
    	if (loaded) {
    		xmlData2 = this.firstChild;
    		arrarylength = xmlData2.childNodes.length;
    		trace(arrarylength);
    		for (i=0; i<arrarylength; i++) {
    			qst[i] = xmlData.firstChild.childNodes[i].attributes.txt;
    			trace(i+" qst[i] = "+qst[i]);
    			for (j=0; j<4; j++) {
    				ans[i][j] = xmlData.firstChild.childNodes[i].childNodes[j].childNodes[0];
    				val[i][j] = xmlData.firstChild.childNodes[i].childNodes[j].attributes.correct;
    				trace(i+" "+j+" ans[i][j] = "+ans[i][j]);
    				trace(i+" "+j+" val[i][j] = "+val[i][j]);
    			}
    		}
    	} else {
    		content = "file not loaded!";
    	}
    }
    My trace kills after the second loop
    Code:
    19
    0 qst[i] = Lead-off hitter Tony Debakey is a quick calculator. Solve this problem: 3/8 + 7/8 =
    0 0 ans[i][j] = 1 1/4
    0 0 val[i][j] = true
    0 1 ans[i][j] = 1 1/2
    0 1 val[i][j] = false
    0 2 ans[i][j] = 7/8
    0 2 val[i][j] = false
    0 3 ans[i][j] = 7/4
    0 3 val[i][j] = false
    1 qst[i] = Tanya Toomey steps up to the plate confident that she knows the answer. Solve this problem: 5/9 - 2/9 =
    1 0 ans[i][j] = 1/3
    1 0 val[i][j] = true
    1 1 ans[i][j] = 1 1/3
    1 1 val[i][j] = false
    1 2 ans[i][j] = 7/3
    1 2 val[i][j] = false
    1 3 ans[i][j] = 1/9
    1 3 val[i][j] = false
    2 qst[i] = Ricky Van Buren takes a cut at this one. Solve this problem: 9/20 x 3/4 =
    2 0 ans[i][j] = undefined
    2 0 val[i][j] = undefined
    2 1 ans[i][j] = undefined
    2 1 val[i][j] = undefined
    2 2 ans[i][j] = undefined
    2 2 val[i][j] = undefined
    2 3 ans[i][j] = undefined
    2 3 val[i][j] = undefined
    3 qst[i] = Clean-up batter Theo Kelly is a sure hit. Solve this problem: 1/2 divided by 1/6 =
    3 0 ans[i][j] = undefined
    3 0 val[i][j] = undefined
    3 1 ans[i][j] = undefined
    3 1 val[i][j] = undefined
    3 2 ans[i][j] = undefined
    3 2 val[i][j] = undefined
    3 3 ans[i][j] = undefined
    3 3 val[i][j] = undefined
    4 qst[i] = Sandy Mayo makes a strong cut. Solve this problem: 4 1/4 + 2 7/8 =
    4 0 ans[i][j] = undefined
    4 0 val[i][j] = undefined
    4 1 ans[i][j] = undefined
    4 1 val[i][j] = undefined
    4 2 ans[i][j] = undefined
    4 2 val[i][j] = undefined
    4 3 ans[i][j] = undefined
    4 3 val[i][j] = undefined
    http://www.wisc-online.com/objects/stc206/stc1062.xml
    Sorry forgot to post the link to the xml
    Last edited by Jdsflash; 10-18-2006 at 02:08 PM. Reason: Forgot link to my xml doc

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