# Loading song, NaN?

**URL:** <https://forum.kirupa.com/t/loading-song-nan/62421>\
**Category:** Uncategorized\
**Created:** [August 27, 2004, 5:03pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421 "2004-08-27T17:03:31Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 27, 2004, 5:03pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421/1 "2004-08-27T17:03:31Z")

</div>

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:

```auto

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

---

<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 27, 2004, 10:24pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421/2 "2004-08-27T22:24:46Z")

</div>

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

---

<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 28, 2004, 10:27am UTC](https://forum.kirupa.com/t/loading-song-nan/62421/3 "2004-08-28T10:27:07Z")

</div>

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

---

<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 28, 2004, 5:31pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421/4 "2004-08-28T17:31:33Z")

</div>

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. 🙂

---

<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 28, 2004, 5:36pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421/5 "2004-08-28T17:36:59Z")

</div>

interesting, that code looks familiar

---

<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 28, 2004, 9:30pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421/6 "2004-08-28T21:30:26Z")

</div>

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

---

<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 10, 2004, 6:39am UTC](https://forum.kirupa.com/t/loading-song-nan/62421/7 "2004-09-10T06:39:29Z")

</div>

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

Thanks

---

<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 11, 2004, 6:27pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421/8 "2004-09-11T18:27:03Z")

</div>

Anyone able to help please??

---

<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 12, 2004, 12:08am UTC](https://forum.kirupa.com/t/loading-song-nan/62421/9 "2004-09-12T00:08:20Z")

</div>

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.

---

<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 12, 2004, 9:58am UTC](https://forum.kirupa.com/t/loading-song-nan/62421/10 "2004-09-12T09:58:52Z")

</div>

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

---

<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, 7:46am UTC](https://forum.kirupa.com/t/loading-song-nan/62421/11 "2004-09-13T07:46:21Z")

</div>

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.

---

<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:45pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421/12 "2004-09-13T17:45:18Z")

</div>

Didn’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:** [September 16, 2004, 3:18pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421/13 "2004-09-16T15:18:40Z")

</div>

Didn’t work

Anyone else able to 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:** [September 17, 2004, 8:57pm UTC](https://forum.kirupa.com/t/loading-song-nan/62421/14 "2004-09-17T20:57:37Z")

</div>

Didn’t work

Anyone else able to help??
