What am I missing?? I am trying to randomly load a simple quote from an xml file. Here is my AS:
var aQuotes:Array = new Array();
var xmlQuotes:XML;
getQuotes("quotes2.xml");
function getQuotes(sURL:String):Void{
xmlQuotes = new XML();
xmlQuotes.ignoreWhite = true;
xmlQuotes.onLoad = function(bSucces:Boolean){
if(bSuccess){
for (var i:Number = 0; i < this.firstChild.childNodes.length; i++){
aQuotes.push(this.firstChild.childNodes*.firstChild.nodeValue);
}
initializeQuotes();
}
};
xmlQuotes.load(sURL);
}
function randomInteger(nRange:Number):Number{
var nRandomFloat:Number = Math.random() * nRange;
var nRandomInteger:Number = Math.floor(nRandomFloat);
return nRandomInteger;
}
function initializeQuotes():Void {
var sQuotes:String = aQuotes[randomInteger(aQuotes.length)];
trace(sQuotes);
}
and then here is my xml:
<randomquotes>
<quote>Hello</quote>
<quote>Goodbye</quote>
<quote>See ya later</quote>
</randomquotes>
I can’t figure this out. Probably because I really don’t know what I am doing. Thanks for any help you can give me.