I am trying to trace out the number of quotes in an XML file, but I am getting a 1 in the output window which I know is incorrect.
In my as I have
//we create a variable to store the loaded XML
var xml:XML;
//the path to the xml file
var xmlPath:String = "data/quotes.xml";
//we create a loader and when the loading is over we call the xmlComplete function
var loader:URLLoader = new URLLoader();
//a url request for our loader
var req:URLRequest = new URLRequest(xmlPath);
loader.addEventListener(Event.COMPLETE, xmlComplete);
loader.load(req);
//a variable for our tween
var myTween:Tween;
//we need to set a timer
var timer:Timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, changeQuotes);
timer.start();
function xmlComplete(e:Event):void{
xml = new XML(e.target.data);
addQuotes();
randomQuoteTween();
trace(xml.quote.length());
}
the XML file look like this:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<quotes>
<quote>
<content>A friend is someone with whom you dare to be yourself.</content>
<author>Frank Crane</author>
</quote>
<quote>
<content>Treat your friends as you do your pictures, and place them in their best light. Treat your friends as you do your pictures, and place them in their best light.</content>
<author>Jennie Jerome Churchill</author>
</quote>
<quote>
<content>A true friend never gets in your way unless you happen to be going down. A true friend never gets in your way unless you happen to be going down.</content>
<author>Arnold H. Glasgow</author>
</quote>
<quote>
<content>The road to a friend's house is never long.</content>
<author>Danish Proverb</author>
</quote>
<quote>
<content>Be a friend to thyself, and others will be so too.</content>
<author>Thomas Fuller</author>
</quote>
</data>
am I putting the trace in the wrong place?