# Music Load Question

**URL:** <https://forum.kirupa.com/t/music-load-question/34192>\
**Category:** flash\
**Created:** [October 29, 2003, 4:11pm UTC](https://forum.kirupa.com/t/music-load-question/34192 "2003-10-29T16:11:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![neverrain](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@neverrain](https://forum.kirupa.com/u/neverrain)\
**Post date:** [October 29, 2003, 4:11pm UTC](https://forum.kirupa.com/t/music-load-question/34192/1 "2003-10-29T16:11:42Z")

</div>

Ok I have a sound Object on the \_root timeline that plays when the page loads, that works great.

I want to preload it so that the user can see the % of it loaded. Here is my code:

[AS]\_root.backgroundMusic.bytes\_loaded = Math.round(\_root.getBytesLoaded());  
\_root.backgroundMusic.bytes\_total = Math.round(\_root.backgroundMusic.getBytesTotal());  
getPercent = bytes\_loaded/bytes\_total;  
loadedBox = Math.round(getPercent\*100)+"%";[/AS]

The Object is names backgroundMusic it is a sound Object (duh).

When I enter that code I get a “NaN%” in the dynamic text box named loadedBox

Thanks.:cap:

---

<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:** [October 29, 2003, 4:16pm UTC](https://forum.kirupa.com/t/music-load-question/34192/2 "2003-10-29T16:16:26Z")

</div>

as was not ment for julian get over it lol

really i have no idea how to do that

---

<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:** [October 29, 2003, 4:34pm UTC](https://forum.kirupa.com/t/music-load-question/34192/3 "2003-10-29T16:34:48Z")

</div>

Ok I updated the code to the following:

[AS]\_root.backgroundMusic.bytes\_loaded = Math.round(\_root.backgroundMusic.getBytesLoaded());  
\_root.backgroundMusic.bytes\_total = Math.round(\_root.backgroundMusic.getBytesTotal());  
\_root.backgroundMusic.getPercent = \_root.backgroundMusic.bytes\_loaded/\_root.backgroundMusic.bytes\_total;  
loadedBox = Math.round(\_root.backgroundMusic.getPercent\*100)+"%";[/AS]

It works in my computer but when I upload it is doesn’t 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:** [October 29, 2003, 6:07pm UTC](https://forum.kirupa.com/t/music-load-question/34192/4 "2003-10-29T18:07:17Z")

</div>

ij try uploading to my coldfusion server and maybe it can 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:** [October 30, 2003, 1:54am UTC](https://forum.kirupa.com/t/music-load-question/34192/5 "2003-10-30T01:54:33Z")

</div>

Here is my code, I try it in my machine and it works but not online…hmm. I asked every Flash forum I know of and they wont reply.

//Loads Background Music  
backgroundMusic = new Sound();  
backgroundMusic.loadSound(“bg\_music.mp3”, false);  
backgroundMusic.start(0, 9999);  
//Preloads The Background Music  
backgroundMusic.bytes\_loaded = Math.round(backgroundMusic.getBytesLoaded());  
backgroundMusic.bytes\_total = Math.round(backgroundMusic.getBytesTotal());  
backgroundMusic.getPercent = backgroundMusic.bytes\_loaded/backgroundMusic.bytes\_total;  
loadedBox = Math.round(backgroundMusic.getPercent\*100)+"%";
