# Loading LoadVars Data as Array Elements

**URL:** <https://forum.kirupa.com/t/loading-loadvars-data-as-array-elements/144634>\
**Category:** Uncategorized\
**Created:** [April 15, 2005, 6:03pm UTC](https://forum.kirupa.com/t/loading-loadvars-data-as-array-elements/144634 "2005-04-15T18:03:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RopeGun](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@RopeGun](https://forum.kirupa.com/u/RopeGun)\
**Post date:** [April 15, 2005, 6:03pm UTC](https://forum.kirupa.com/t/loading-loadvars-data-as-array-elements/144634/1 "2005-04-15T18:03:06Z")

</div>

Hello AS experts.

I am trying to create an array where each element is a different text string that is loaded from separate external text files. What I have below almost works – I can load in and trace each of the different strings at each step of the loop, but I cannot get them to be plugged into each element of an array. See below for the output when running this script. I know the problem lies at the line where I wrote: **[color=red]Doesn’t work![/color]**. Does anybody know what I need to have here to make this work?

```auto

function createTitleArray() {
var i:Number = 0;
var n:Number = Number(slideTotalLV.slideTotal); **//from another LoadVars and is equal to "7" (an integer)**
var slideTitleLV:LoadVars = new LoadVars();
var imgTitle:Array = new Array(n);
while (i < n) {
slideTitleLV.load("../var/info_" + i + ".txt"); **//opens files named "info_0.txt", "info_1.txt", ... , "info_6.txt"**
slideTitleLV.onLoad = function(success:Boolean) {
if (success) {
trace(slideTitleLV.title + " [from loop]"); **//in each of the *.txt files there is a variable "title" that is equal to some text. These are traced correctly in the Output panel**
}
}
imgTitle**= String(slideTitleLV.title);**//[u][color=red]Doesn't work![/color][/u] Here is where I am trying to place contents of each "title" variable in an element of an array.***
*i += 1;*
*}*
*trace("titleArray = " + imgTitle + " [end]"); **//"undefined" gets traced as each of the seven elements in the array.***
*}*
*

```

- 

_OUTPUT_

_titleArray = undefined,undefined,undefined,undefined,undefined,undefined,undefined [end]_  
_First Test Title [from loop] **// these seven rows were retrieved from the “title” variable from the “info\_0.txt”, “info\_1.txt”, … , “info\_6.txt” external file sequences.** _  
_Second Test Title [from loop]_  
_Third Test Title [from loop]_  
_Fourth Test Title [from loop]_  
_Fifth Test Title [from loop]_  
_Sixth Test Title [from loop]_  
_Seventh Test Title [from loop]_

_What I want is for these last seven lines to be the elements in the array that has only “undefined” elements._

_Please help…losing my mind_

_Regards,_

\*-john \*

_edited by **digitalosophy** : I wrapped your code in as tags, your post was very hard to read._
