# Loading MP3's with Dynamic Text preloader

**URL:** <https://forum.kirupa.com/t/loading-mp3s-with-dynamic-text-preloader/35639>\
**Category:** Uncategorized\
**Created:** [November 16, 2003, 10:29am UTC](https://forum.kirupa.com/t/loading-mp3s-with-dynamic-text-preloader/35639 "2003-11-16T10:29:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cameron](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@Cameron](https://forum.kirupa.com/u/Cameron)\
**Post date:** [November 16, 2003, 10:29am UTC](https://forum.kirupa.com/t/loading-mp3s-with-dynamic-text-preloader/35639/1 "2003-11-16T10:29:29Z")

</div>

I’m trying to construct an MP3 audio player that when the user clicks on one of the audio clips a Dynamic Text box comes up saying “Downloading…”. Problem is that the Dynamic Text stays on the screen after the song has loaded. Currently there is also an “else” statement that shows “Song Loaded” if the screen is refreshed after a period of time. Question? How do I get the Dynamic Text to disappear when the audio is cached and have the audio start to play?

Currently my script is as follows:

First Frame Action Script:

```auto
 
mySound = new Sound(audio);
// create a sound object
mySound.loadSound("test.mp3", true);
// attach and cache external sound file
mySound.stop();
// stop sound object from playing

```

Play Button Action Script:

```auto
 
on (press) {
	downloaded = mySound.getBytesLoaded(audio);
	total = mySound.getBytesTotal(audio);
	if (downloaded != total) {
		textbox = "downloading song...";
		// textbox is the text area
	} else {
		textbox = "Song Loaded";
		// textbox is the text area
		mySound.loadSound("test.mp3", true);
		// The audio should start to play here
	}
}

```

I’ve also reviewed the excellent work by Kenny Bellew at [http://www.kennybellew.com/](http://www.kennybellew.com/) but have not found anything that I am looking for.

If you wanted to see this in action go to the following URL  
[http://www.aull.com/test/test.html](http://www.aull.com/test/test.html)  
Thanks in advance for all the help!  
:-\

---

<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:** [August 31, 2004, 10:40pm UTC](https://forum.kirupa.com/t/loading-mp3s-with-dynamic-text-preloader/35639/2 "2004-08-31T22:40:11Z")

</div>

Cameron,  
It has been a while since you posted this but I have a question.  
The preloader almost works for me but after it loads, it doesn’t display “Song loaded” unless you stop and restart the song. My code is different because of the array.  
Any ideas?

music = new Array(“music1.mp3”,“music2.mp3”, “music3.mp3”, “music4.mp3”,“music5.mp3”,“music6.mp3”,“music7.mp3”,“music8.mp3”,“music9.mp3”);  
currenttrack = 0  
function stopmysound(){  
trace (“function stop sounds works!”);  
slideSound.stop();  
}

function changeTrack(number){  
if (number \>= 0 && number \< music.length){  
currentTrack = number;  
slideSound.stop();  
slideSound = new Sound();  
slideSound.loadSound(“music/”+ music[number], true);  
//loading bar

```
downloaded = slideSound.getBytesLoaded(audio);
total = slideSound.getBytesTotal(audio);
if (downloaded != total) {
	textbox = "downloading song...";
	// textbox is the text area
} else {
	textbox = "Song Loaded";
	// textbox is the text area
	// The audio should start to play here
}

```

> [@Cameron](#):
>
> I’m trying to construct an MP3 audio player that when the user clicks on one of the audio clips a Dynamic Text box comes up saying “Downloading…”. Problem is that the Dynamic Text stays on the screen after the song has loaded. Currently there is also an “else” statement that shows “Song Loaded” if the screen is refreshed after a period of time. Question? How do I get the Dynamic Text to disappear when the audio is cached and have the audio start to play?
> 
> Currently my script is as follows:
> 
> First Frame Action Script:
> 
> ```auto
>  
> mySound = new Sound(audio);
> // create a sound object
> mySound.loadSound("test.mp3", true);
> // attach and cache external sound file
> mySound.stop();
> // stop sound object from playing
> 
> ```
> 
> Play Button Action Script:
> 
> ```auto
>  
> on (press) {
> downloaded = mySound.getBytesLoaded(audio);
> total = mySound.getBytesTotal(audio);
> if (downloaded != total) {
> textbox = "downloading song...";
> // textbox is the text area
> } else {
> textbox = "Song Loaded";
> // textbox is the text area
> mySound.loadSound("test.mp3", true);
> // The audio should start to play here
> }
> }
> 
> ```
> 
> I’ve also reviewed the excellent work by Kenny Bellew at [http://www.kennybellew.com/](http://www.kennybellew.com/) but have not found anything that I am looking for.
> 
> If you wanted to see this in action go to the following URL  
> [http://www.aull.com/test/test.html](http://www.aull.com/test/test.html)  
> Thanks in advance for all the help!  
> :-\
