I am a newcomer to Flash. The following script is taken from
http://www.tutorialized.com/tutorial/Making-a-simple-Mediaplayer-in-Flash-MX/9877
What I dont understand are the possible reasons why it should run absolutely fine in Flash App with Ctrl + ENter, but when on a local or remote server in web page, for some reason
bt = snd.getBytesTotal();
is empty.
When testing on server:
The file path to the music is ok, cos that plays still .
The dynamic text is fleetingly populated with NaN%, which I think implies some division by zero somewhere.
Anybody any ideas?
soundUrls = new Array(“loop1.mp3”,“loop2.mp3”,“loop3.mp3”);
btn1.nr = 0;
btn1.number_txt.text = btn1.nr+1;
btn2.nr = 1;
btn2.number_txt.text = btn2.nr+1;
btn3.nr = 2;
btn3.number_txt.text = btn3.nr+1;
snd = new Sound();
snd.onLoad = function (succes) {
if (succes) {
snd.start(0, 999);
} else {
trace(“loading failed”);
}
}
switchTrack = function (trackNr) {
snd.stop();
snd.loadSound("./flash/tunes/"+soundUrls[trackNr]);
[COLOR=DarkOrchid]** bt = snd.getBytesTotal();
trace("BytesTotal - "+bt);
this.onEnterFrame = function () {
bl = snd.getBytesLoaded();
pr = bl/bt*100;
bar_mc.percent_txt.text = Math.floor(pr)+’%’;
bar_mc._xscale = pr;
if (pr == 100) {
delete this.onEnterFrame;**[/COLOR]
}
}
}