# Looping through a txt file & attachMovie()

**URL:** <https://forum.kirupa.com/t/looping-through-a-txt-file-attachmovie/155507>\
**Category:** Uncategorized\
**Created:** [July 18, 2005, 1:08pm UTC](https://forum.kirupa.com/t/looping-through-a-txt-file-attachmovie/155507 "2005-07-18T13:08:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakob](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/yakob/32/348_2.png) [@yakob](https://forum.kirupa.com/u/yakob)\
**Post date:** [July 18, 2005, 1:08pm UTC](https://forum.kirupa.com/t/looping-through-a-txt-file-attachmovie/155507/1 "2005-07-18T13:08:32Z")

</div>

hey out there,

just read the tutorial at [http://www.kirupa.com/developer/mx/externaldata.htm](http://www.kirupa.com/developer/mx/externaldata.htm) and it got me thinking…

i’ve gotta load of cd track listings i need to show. all the info is in text files, and i can format it to look like:

totalTracks=2  
&trackInfo1=Square One  
&trackFile1=01\_Square\_One.mp3  
&trackInfo2=What If?  
&trackFile2=what\_if.mp3

i’ve been trying to use this actionscript to loop through each track and attach it to the stage:

```auto
stop();

loadText = new LoadVars();
loadText.load("cd1.txt");
loadText.onLoad = function() {
	
	//count the number of tracks
	arrayLength = this.totalTracks;
		
	//each movie clip has to be offset
	vertOffset = 55;
	
	//loop through each value in the array
	for (i=0; i<arrayLength; i++) {
		
		//attach the clip
		var tClip = this.attachMovie("trackInfoMc", "track"+i, this.getNextHighestDepth());
		
		trace(tClip);
		
		//set it's y position
		tClip._y = vertOffset+(tClip._y+vertOffset)*i;
		
		//set the txt inside the new mc to the current value
		tClip.trackInfo.text = this.trackInfo*;
		tClip.trackFile.text = this.trackFile*;
	
	}
};

```

the final idea is to turn each loop into a click link that loads the mp3 into a media player - i need to get this working 1st!

at the moment, nothing appears on the timeline.

can anyone see what i’m doing wrong or am i approaching this the wrong way…

anything would be great!

many thanks,

jake
