Salve il problema è il seguente, ho un file fla, al primo frame richiamo un file esterno con il codice as, il codice non fa altro che richiamare una classe che deve restituire un parametro, corrispondente al nome di un file xml, poi in base a questo parametro leggo un file xml.
In pratica la classe legge un file xml e poi estrae in modo random un nodo di questo xml e lo dovrebbe restituire al codice as che prende questo parametro e legge un xml,il problema nasce per il fatto che quando richiamo la classe, si fa la funzione leggiListDay poi ritorna al codice as senza passare per il loadXmlDay, penso che dipenda dai tempi ma come la posso gestire questa cosa??
Codice PHP:
class leggiListDay {
var itemRandom:String;
function leggiListDay() {
var intRandom:Number;
var arr:XML = new XML ();
//Carica
arr.ignoreWhite = true;
arr.onLoad = function (success) {
loadXMLDay (success, arr);
};
var xml_data_file = "../items/ListDay.xml";
arr.load (xml_data_file);
}
function loadXMLDay (success, arr) {
if (success) {
var rootNode = arr.firstChild;
var total = rootNode.childNodes.length;
var arrXML:Array = new Array();
trace("///////////////////////////////////////////////////////////////////");
var r:Number;
for (r = 0; r <= total-1; r++) {
var strId:String = rootNode.childNodes[r].attributes.id;
var strRif:String = rootNode.childNodes[r].attributes.rif;
arrXML[r] = {Id: strId, Rif: strRif}
trace("ID: " + strId);
trace("ID Rif: " + strRif);
}
trace("///////////////////////////////////////////////////////////////////");
var intRandom = randRange(0, (total-1)); //generazione di un numero random tra 0 e il numero massimo dell'array
this.itemRandom = intRandom;
}
}
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
}
function generaRandomItem():String {
return itemRandom;
}
}