Problem accessing Array

Hi, I’ve done the following

[AS]
playList_lv = new LoadVars();
playList_lv.load(“playlist.txt”);
playList_lv.onLoad = function(){
_root.playList1 = this.playlist.split(";");

}
trace(_root.playList1);

[/AS]

and for playlist.txt:
playlist=a;b;c

trace returns undefined.
but when i place trace inside the onload function,…

[AS]
playList_lv = new LoadVars();
playList_lv.load(“playlist.txt”);
playList_lv.onLoad = function(){
_root.playList1 = this.playlist.split(";");
trace(_root.playList1);
}

[/AS]

trace gives me a,b,c. am i missing out something? i cant seem to access the array from outside onLoad() …

that’s because the actions inside onLoad() {} are triggered once the text file is loaded but the ones outside are triggered immediately. So the trace outside the onLoad() {} is triggered before the text file is even loaded…

Oh. Is there anyway i can load the text file first, get the array filled, then let the rest of the actionscripts (like the trace command) access the array?

Wow I solved my own question. I just force the movie to pause until the text file has been loaded… Thanks syko :slight_smile:

You don’t have to force the movie to pause: you can use the parameter of the LoadVars.onLoad (isSuccess).