PDA

View Full Version : sound


joeri
10-13-2002, 01:18 PM
Hi out there!

I want to ask something about the following script :

++++++++++++++++++++++++++++++++++++++++++++++

bladeSound = new Sound();
bladeSound.loadSound("music/blade rave.mp3",false);
total = bladeSound.getBytesTotal();

_root.onEnterFrame = function(){

loaded = bladeSound.getBytesLoaded();
percent = Math.round((loaded/total) * 100);
//trace(percent);
}
//trace(percent);
if(percent == 100){
bladeSound.start();}


++++++++++++++++++++++++++++++++++++++++++++++

1) When the swf loads the mp3 the dynamic textfield shows 'Infinity' ?? I rounded it........??

2)When I trace the percent after the onEnterFrame block it prints
level0.percent....???
percent should be known after the block?? Isnt it?


thanx, Joeri

Billy T
10-13-2002, 02:14 PM
was working ok for me

you want to make sure you're not setting the total var before the sound has even started loading

also, you need to put the if statement inside the enterFrame handler

try something like this

bladeSound = new Sound();
bladeSound.loadSound("yourSound.mp3", false);
_root.onEnterFrame = function() {
total = bladeSound.getBytesTotal();
loaded = bladeSound.getBytesLoaded();
percent = Math.round((loaded/total)*100);
if (percent == 100) {
bladeSound.start();
_root.onEnterFrame = null;
}
};


cheers

Billy T
10-13-2002, 02:15 PM
oh and I wouldnt have a space in the mp3 file name either...

joeri
10-13-2002, 03:01 PM
great!

the two tips you gave me seem okay but it still doesnt work.....

check : http://joeri.does.it

the textfield first shows NaN and then jumps to 100 ......

there must be something wrong with the computation

but I dont get a clue...

Or is it something else?

PS. the real path of the site is : http://home.student.uva.nl/joeri.honnef

Billy T
10-13-2002, 11:50 PM
worked fine...

joeri
10-14-2002, 10:18 AM
Hi,


It works fine on the computers at my work.....!

I dont understand it didnt work at home??

I use IE 6 in combination with XP and flash MX so it should work

there too!

Perhaps you know what the problem could be...

thanx, Joeri