# Populating array from textfile... and using it!

**URL:** https://forum.kirupa.com/t/populating-array-from-textfile-and-using-it/54347
**Category:** Uncategorized
**Created:** [June 13, 2004, 9:12pm UTC](https://forum.kirupa.com/t/populating-array-from-textfile-and-using-it/54347 "2004-06-13T21:12:06Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![radioxromance](https://avatars.discourse-cdn.com/v4/letter/r/9e8a1a/32.png) [@radioxromance](https://forum.kirupa.com/u/radioxromance)
#### Post date: [June 13, 2004, 9:12pm UTC](https://forum.kirupa.com/t/populating-array-from-textfile-and-using-it/54347/1 "2004-06-13T21:12:06Z")

</div>

Okay so I am new to using txt files, and not too great with arrays, but I think I should have this right. But when I try to trace the array, I get undefined!  
I found this on another thread, and changed it accordingly.

```auto

_root.textArray = new Array();
_root.text_lv = new LoadVars();
_root.text_lv.onLoad = function(success) {
	if (success) {
		_root.textArray = this.texts.split(",");
	}
};
_root.text_lv.load("links.txt");
trace(_root.textArray[0]);

```

I changed a few thigns such as adding \_root cause I thought maybe for some reason it was scope, but that didn’t fix it. But if I trace it inside the success if, I get the proper trace! WHY?
