View Single Post
Old 25-10-2009, 16:41   #1
ale09hh
Senior Member
 
L'Avatar di ale09hh
 
Iscritto dal: Jan 2008
Messaggi: 430
[Actionscript 2.0] Codice che non ciene compilato in ordine

Ciao a tutti

io ho questo codice

Codice:
var myXML:XML = new XML();

_global.canzone = new _global.Array();
_global.file = new _global.Array();

myXML.ignoreWhite=true;
myXML.load("playlist.xml");
myXML.onLoad = function(success){
	
if (success){
	var mySong = myXML.firstChild.childNodes;	
	
		for(i=0; i<mySong.length; i++){
			
			var songNumber = mySong[i].attributes.number;
			var songName = mySong[i].attributes.name;
			var songFile = mySong[i].attributes.file;
			_global.canzone[i]=songName;
			_global.file[i]=songFile;
			trace(file[i]);
			trace ("My song number "+songNumber+" is titled "+songName+" and its FileName is "+songFile+".")
		}

	
	}  else {
	trace("Error loading playlist.xml");
	}

}



trace(file[1]);
che fondamentalmente funziona...

...MA...

... mi esegue per prima l'istruzione che ho scritto per ultima (il trace(file[1]))

ecco l'output:

Codice:
undefined
music.mp3
My song number 1 is titled Kanye West - Amazing and its FileName is music.mp3.
music2.mp3
My song number 2 is titled Hego - Ridin' and its FileName is music2.mp3.
in pratica è l'undefined all'inizio che da problemi.. Che deriva appunto dal trace() finale...

L'ho scoperto xk togliendolo non esce più undefined...

PERCHE' ME LO ESEGUE ALL'INIZIO???? E' logico che se lo esegue lì l'array non è ancora definito...

E il bello è che se metto il trace() associato ad un bottone (quindi lo eseguo dopo) funziona..

Qualcuno mi può aiutare? GRAZIE!!!
__________________
[ Raidmax Ninja | Intel [email protected] Ghz | Arctic Cooling Freezer 7 Pro | Asus P5K-E WiFi-AP | 6GB Corsair 800Mhz | XFX HD5770XT | 2xWestern Digital 320GB Raid0 | Pioneer DVR-215D | LG L222WS ]
ale09hh è offline   Rispondi citando il messaggio o parte di esso