# Problem accessing Array

**URL:** <https://forum.kirupa.com/t/problem-accessing-array/38842>\
**Category:** flash\
**Created:** [December 30, 2003, 2:45pm UTC](https://forum.kirupa.com/t/problem-accessing-array/38842 "2003-12-30T14:45:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lira](https://avatars.discourse-cdn.com/v4/letter/l/8e8cbc/32.png) [@lira](https://forum.kirupa.com/u/lira)\
**Post date:** [December 30, 2003, 2:45pm UTC](https://forum.kirupa.com/t/problem-accessing-array/38842/1 "2003-12-30T14:45:57Z")

</div>

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() …

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 30, 2003, 2:49pm UTC](https://forum.kirupa.com/t/problem-accessing-array/38842/2 "2003-12-30T14:49:43Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 30, 2003, 2:52pm UTC](https://forum.kirupa.com/t/problem-accessing-array/38842/3 "2003-12-30T14:52:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 30, 2003, 3:05pm UTC](https://forum.kirupa.com/t/problem-accessing-array/38842/4 "2003-12-30T15:05:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 30, 2003, 5:49pm UTC](https://forum.kirupa.com/t/problem-accessing-array/38842/5 "2003-12-30T17:49:02Z")

</div>

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