# LoadVars() problem!

**URL:** https://forum.kirupa.com/t/loadvars-problem/166787
**Category:** Uncategorized
**Created:** [October 22, 2005, 9:19pm UTC](https://forum.kirupa.com/t/loadvars-problem/166787 "2005-10-22T21:19:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![th3Phallex](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@th3Phallex](https://forum.kirupa.com/u/th3Phallex)
#### Post date: [October 22, 2005, 9:19pm UTC](https://forum.kirupa.com/t/loadvars-problem/166787/1 "2005-10-22T21:19:07Z")

</div>

Ok, so i’ve searched thru the forums with no real answer to what I am looking for.

I have on one file (player1.fla), a movie that plays MP3s from an array, which I specify in that movie. The code for that works just fine.

I’ve duplicated the file and renamed it to a different one (player2.fla) so I could load the MP3s from a variable (array) on a text file. This way, to add more songs, all I would have to do is update the text file.

I changed the code around a tiny bit in the “player2.fla” file to accomodate for loading a text file, **but nothing more.**

[size=3][color=red]_ **My Problem** _[/color][/size]  
\*\*The text file loads properly and displays the Title of the mp3, but it won’t play the mp3! \*\*  
**WTF!**

**HELP PLEASE!!**

The text file looks something like this: (just an example)

```auto

&songs=song1.mp3, song2.mp3, song3.mp3
&songTitles=my song1, my newer song, the third song

```

My script is very similar to this: (shortened; just an example)

```auto

lv = new LoadVars(); 
lv.onLoad = function() {
 
//store current url in global variable
prevUrl = null;
// store playstate in global variable
isPlaying = false; 
 
// create Arrays
mp3Array = new Array(); 
mp3NamesArray = new Array();
 
// fill Arrays with names and titles
mp3files = this.songs; 
mp3Array = mp3files.split(",");
 
mp3titles = this.songTitles; 
mp3TitlesArray = mp3titles.split(",");
 
 
 
// define the path to the mp3s
myPath = "C:\mp3s\" // for some reason, KirupaForum strips the slashes, but they're in there
 
// define a file to play
mp3Num = random(mp3Array.length-1); // picks a random number from the array
 
mp3ToPlay = myPath+mp3Array[mp3Num];
 
 
 
// a function that sets up the SoundContainer object
function createSoundObject(){
soundContainer = new Sound(this); // define sound object
soundContainer.onSoundComplete = updateStatus; // change state at song end
soundContainer.setVolume(100);
return;
}
 
// do the function above to create the SoundObject
createSoundObject();
 
 
 
// the "playSnd" function that actually plays the mp3
function playSnd(url){
// check playstate
if(isPlaying){ 
return; // deactivate PLAY button during play/load
} else {
isPlaying = true;
}
 
// check if same or new mp3
if(prevUrl != url){ // new mp3
soundContainer.loadSound(url,true); // sound automtically plays afer loading
prevUrl = url;
} else if(soundContainer.position > (soundContainer.duration - 100)){ // same file
soundContainer.start(0); // replay from beginning 
} else { // same file
soundContainer.start(soundContainer.position/1000); // start song at last paused
}
}
 
 
// play the mp3 file and load the title into a textbox
playSnd(mp3ToPlay);
trace("song to load: "+mp3ToPlay); //THIS WORKS! it tells me the complete filename, but it won't play this file! WHY?!
 
textbox = mp3TitlesArray[mp3Num]; //THIS WORKS! it displays the Song Title correctly.
 

```
