Skip to main content
Participant
July 31, 2008
Answered

Sound.getBytesLoaded proplems, help!

  • July 31, 2008
  • 7 replies
  • 683 views
I am trying to program a preloader for external MP3 files,
the sound var is called MP3ToPlay so i figure my code should be as follows;

bytes_loaded = Math.round(_root.MP3ToPlay.getBytesLoaded());
bytes_total = Math.round(_root.MP3ToPlay.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
loadText1 = Math.round(getPercent*100)+"%";

Though in the text box all i am getting is NaN%
what might this problem be?
source files online at
http://www.philipbell.org/drphil/webtest/
This topic has been closed for replies.
Correct answer kglad
that code needs to execute repeatedly. if you put trace(_root.MP3ToPlay) near that code, you should see [object Object] repeatedly.

7 replies

kglad
Community Expert
Community Expert
August 1, 2008
bytes_total must be zero.
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
August 1, 2008
that code needs to execute repeatedly. if you put trace(_root.MP3ToPlay) near that code, you should see [object Object] repeatedly.
bellp629Author
Participant
August 1, 2008
Thanks!
It's working, although for a split second before the numbers start loading it still reads NaN% do you have any idea why it's registering like that?
bellp629Author
Participant
July 31, 2008
when i put in trace(_root.MP3ToPlay)
the output stated
[object Object]
if by being in a loop you mean its ever present in the mc than yes it spans the entirety of the mc.
(sorry about the low lingo knowledge I'm new at this)
kglad
Community Expert
Community Expert
July 31, 2008
wha'ts trace(_root.MP3ToPlay) reveal?

and that code is in a loop, correct?
kglad
Community Expert
Community Expert
July 31, 2008
is you sound loading? if so, make sure _root.MP3ToPlay is the correct reference to your sound object by using a trace(_root.MP3ToPlay)
bellp629Author
Participant
July 31, 2008
The sound is loading, and my var is declared as follows;

var MP3ToPlay:Sound = new Sound();

even when i attach the trace function _root.MP3ToPlay
it still comes out as NaN%
I'm stumped.
bellp629Author
Participant
July 31, 2008
sorry, it was a typo. The Sound var is called MP3ToPlay
kglad
Community Expert
Community Expert
July 31, 2008
what's MP3ToLoad relationship to _root.MP3ToPlay