Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML problem in bar chart app

Status
Not open for further replies.

stevet26

Programmer
Feb 9, 2005
53
Hi

I am a Flash Newbie and a project has kind of been forced upon me by the powers that be. So I have been muddling through and got to a point which is really puzzling me.

Basically I have and XML file which holds monthly referrer data. Only one months worth at the mo.

Code:
<stats>
	<item>
               <year>2007</year>
               <month>March</month>
               <hitcount>7</hitcount>
               <submit>3</submit>
        </item>
</stats>

What I am trying to do is read in this data and use it to build a bar chart.

This is done by looping though the <items>, adding a movie clip to the stage and using the <hitcount> value to determine the _x value of the movie clip.

This was all going swimmingly up until it had to get the values out of the XML file. All I keep getting is either undefined messages or a null value. This is very frustrating

Here is the actionscript code I am working with

Code:
fscommand("allowscale", false);
fscommand("showmenu", false);

//Set Variables
var R_ID:String ="1";
var FilePath:String ="[URL unfurl="true"]http://localhost/";[/URL]
var myXML:XML = new XML();

//Load in the XML file
myXML.ignoreWhite = true;
myXML.onLoad = checkUpload;
myXML.load(FilePath+"XMLFile.xml");

function checkUpload(success) {
        if(success == true) {
			var i:Number;
			var root = myXML.firstChild;
				
				y_Int = 25;
				
				for (i=0; i<root.childNodes.length; i++) {
						
					_root.attachMovie("whole_bar","bar"+i, i);
					_root["bar"+i]._x = 20;
					_root["bar"+i]._y = y_Int;
									
					_root["bar"+i].bar._xscale = root.childNodes[i].childNodes[2].value;
					
					_root["bar"+i].iCount.text = root.childNodes[i].childNodes[2].value;
									
					_root["bar"+i].txtMonthName.text = root.childNodes[i].childNodes[1].value + " " + root.childNodes[i].childNodes[0].value ;
					
					y_Int += 20;
						
				} 
		} else {
			trace("Error loading XML")
			stop();
		}
}

If anyone can shed some light as to why I am unable to get these values out of the XML file it would be much appreciated.

Thanking you in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top