# Audio preloader not working

**URL:** <https://forum.kirupa.com/t/audio-preloader-not-working/64022>\
**Category:** Uncategorized\
**Created:** [September 12, 2004, 4:30pm UTC](https://forum.kirupa.com/t/audio-preloader-not-working/64022 "2004-09-12T16:30:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanel96](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@tanel96](https://forum.kirupa.com/u/tanel96)\
**Post date:** [September 12, 2004, 4:30pm UTC](https://forum.kirupa.com/t/audio-preloader-not-working/64022/1 "2004-09-12T16:30:44Z")

</div>

i’m getting deseprate by now… i’ve been trying to get my audio preloader to work for 7h straight, and no positive results… it should be simple:

// actions on main timeline frame 1  
stop();  
my\_sound = new Sound();  
my\_sound.loadSound(“song.mp3”, false);

// actions of a movie clip named mc\_preloader that is also on the main timeline frame 1

onClipEvent(load){  
bytestotal = \_root.my\_sound.getBytesTotal();  
}  
onClipEvent(enterFrame){  
bytesloaded = \_root.my\_sound.getBytesLoaded();  
\_root.loaded.text = bytesloaded;  
}

// there is also a dynamic text box on the first frame in the main timeline with an instance name of “loaded”

And it doesnt show the bytes loaded… i’m about to kill myself… why isn’t it working ?

---

<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:** [September 13, 2004, 5:18am UTC](https://forum.kirupa.com/t/audio-preloader-not-working/64022/2 "2004-09-13T05:18:41Z")

</div>

ok, try this, get rid of all those actions on the movie clip, erase your timeline actions too. replace your timeline actions with this :

```auto

mySound = new Sound(this);
mySound.loadSound("song.mp3")
loadBar._width = 0;
this.onEnterFrame = function() {
	total = myMusic.getBytesTotal();
	loaded = myMusic.getBytesLoaded();
	percent = Math.round((loaded/total)*100);
	loadText = percent+"%";
	this.loadBar._width = percent;
	if (loaded == total && total > 0) {
		myMusic.start(0,1);
		delete this.onEnterFrame;
	}
};

```

make sure your preloader bar instance name is “loadBar” or it wont work.

---

<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:** [September 13, 2004, 6:30am UTC](https://forum.kirupa.com/t/audio-preloader-not-working/64022/3 "2004-09-13T06:30:58Z")

</div>

i changed the code a little… but it still doesn’t work, shows 100% all the time.

```auto
 mySound = new Sound(this); 
mySound.loadSound("Song.mp3");
loadBar._width = 0;
this.onEnterFrame = function() {
	total = mySound.getBytesTotal();
	loaded = mySound.getBytesLoaded();
	percent = Math.round((loaded/total)*100);
	loadText = percent+"%";
	_root.percentage.text = loadText;
	this.loadBar._width = percent;
	if (loaded == total && total>0) {
		myMusic.start(0, 1);
		delete this.onEnterFrame;
	}
};

```

---

<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:** [September 13, 2004, 8:10am UTC](https://forum.kirupa.com/t/audio-preloader-not-working/64022/4 "2004-09-13T08:10:13Z")

</div>

2 questions:

1. did you make sure you named your movieclip instance “loadBar” ?

2. do you have everything targeted correctly…like your loadBar movieclip?

of all thats correct then post your .fla and ill look at it. i had this exact same problem a while back.

---

<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:** [September 13, 2004, 9:49am UTC](https://forum.kirupa.com/t/audio-preloader-not-working/64022/5 "2004-09-13T09:49:25Z")

</div>

thanks for helping me… the sound thing seems completely impossible… i’ll post the \*.fla file in 20 minutes

---

<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:** [September 13, 2004, 10:01am UTC](https://forum.kirupa.com/t/audio-preloader-not-working/64022/6 "2004-09-13T10:01:38Z")

</div>

here’s the file… it just shows 100% all the time ☹

EDIT: \*\*\*\*… now it seems to be working… when i simulated the download progress through FlashMx on my hard drive it showed 100% all the time… but when i uploaded it to the internet it worked perfectly :-/
