Loading song, NaN?

Hey, I have an mp3 on my little site, but when It is supposed to load, instead of the percentage number, its just says NaN, anyone know why?
Here my code:


AudioXml = new XML();
AudioXml.ignoreWhite = true;
AudioXml.onLoad = LoadXmlFile;
AudioXml.load(playListPath);
function LoadXmlFile(success) {
 if (success) {
  aPath = new Array();
  asongTitle = new Array();
  aAudio = new Array();
  aAudio = this.firstChild.childNodes;
  AudioTotal = aAudio.length;
  for (i=0; i<AudioTotal; i++) {
   if (aAudio*.nodeName == "AudioProps") {
	aPath.push(aAudio*.attributes.path);
	asongTitle.push(aAudio*.attributes.songTitle);
   }
  }
  AudioPath = aPath[0];
  tAuthor = asongTitle[0];
  AudioActual = 1;
  tCount = AudioActual+" Of "+AudioTotal;
  tText = "Xml Loaded";
 } else {
  tText = "Xml not loaded";
 }
}
Ff.onPress = function() {
 if (AudioActual<AudioTotal) {
  AudioActual += 1;
  AudioPath = aPath[AudioActual-1];
  tAuthor = asongTitle[AudioActual-1];
  MySound.stop();
  Mystatus = "Press Play";
 }
};
Rw.onPress = function() {
 if (AudioActual>1) {
  AudioActual -= 1;
  AudioPath = aPath[AudioActual-1];
  tAuthor = aSongTitle[AudioActual-1];
  MySound.stop();
  Mystatus = "Press Play";
 }
};
PlayBtn.onPress = function() {
 if (FlagPausa == true) {
  MySound.start(SoundPausePos, 0);
  FlagPausa = false;
  SoundPausePos = undefined;
 } else {
  MySound = new Sound();
  volume = 100;
  MySound.setVolume(volume);
  MySound.loadSound(AudioPath, StreamFlag);
  FlagPausa = false;
  _parent.onEnterFrame = function() {
   TB = MySound.getBytesTotal();
   BL = MySound.getBytesLoaded();
   if (BL != TB) {
	TheText2.text = Math.round((BL/TB)*100)+"% Loaded";
   } else {
	TheText2.text = "100% Loaded";
	delete _parent.onEnterFrame;
	MySound.start();
   }
  };
 }
};
StopBtn.onPress = function() {
 MySound.stop();
 Mystatus = "Press Play";
};
PauseBtn.onPress = function() {
 SoundPausePos = MySound.position/1000;
 MySound.stop();
 FlagPausa = true;
};
volUp.onPress = function() {
 if (volume == 100) {
  volume = 100;
 } else {
  volume += 10;
  MySound.setVolume(volume);
 }
};
volDown.onPress = function() {
 if (volume == 0) {
  volume = 0;
 } else {
  volume -= 10;
  MySound.setVolume(volume);
 }
};

Thanks,
fatnslow

nope.
u tried putting tracers in for BL and TB?
also, have you tried swapping out theText2.text for a variable and tracing that (or setting that as a text boxes text)

Prophet.

PS actually, looking at it again, it looks like it could be a pathing problem… if you are using _parent.onEnterFrame dont forget that the arguements inside will have a this value of the movieclip itself, NOT where you have defined the code… if that makes ANY sense what so ever! lol

Hmm, didn’t make sense for me, newbie with as you see :frowning:

NaN = Not a number. look for where you’re setting a variable that has to be a number.
by looking at your code, i’m thinking it’s the StreamFlag variable.
you haven’t set it and yet you are trying to use it to load the sound. :slight_smile:

interesting, that code looks familiar

Probably does, its very like a mp3 component a friend of mine had.
I’ll see if I can find it out, cyberathlete

Anyone able to help here? Having some trouble finding it out…

Thanks

Anyone able to help please??

try tracing variables BL and TB and see if both of them are numbers, and not undefined which would generate the error you are describing.

Ok, I used
trace (BL);
and
trace (TB;

to check them, and they both turned out to be undefined. How do I get it to work?

Real noob on as

Thanks,
fatnslow

hey, i have no idea if this will help, but i had a Nan issue with a dynamic preloader and the reason was because i typed the typed the filename incorrectly in my code. go back and look at how you have the .mp3 on your server spelled. and make sure if a letter is capitalized you type it the same exact way in your code. that may not be it at all, but give it a check just to make sure.

Didn’t work :frowning:

Didn’t work

Anyone else able to help??

Didn’t work

Anyone else able to help??