I’m trying to construct an MP3 audio player that when the user clicks on one of the audio clips a Dynamic Text box comes up saying “Downloading…”. Problem is that the Dynamic Text stays on the screen after the song has loaded. Currently there is also an “else” statement that shows “Song Loaded” if the screen is refreshed after a period of time. Question? How do I get the Dynamic Text to disappear when the audio is cached and have the audio start to play?
Currently my script is as follows:
First Frame Action Script:
mySound = new Sound(audio);
// create a sound object
mySound.loadSound("test.mp3", true);
// attach and cache external sound file
mySound.stop();
// stop sound object from playing
Play Button Action Script:
on (press) {
downloaded = mySound.getBytesLoaded(audio);
total = mySound.getBytesTotal(audio);
if (downloaded != total) {
textbox = "downloading song...";
// textbox is the text area
} else {
textbox = "Song Loaded";
// textbox is the text area
mySound.loadSound("test.mp3", true);
// The audio should start to play here
}
}
I’ve also reviewed the excellent work by Kenny Bellew at http://www.kennybellew.com/ but have not found anything that I am looking for.
Cameron,
It has been a while since you posted this but I have a question.
The preloader almost works for me but after it loads, it doesn’t display “Song loaded” unless you stop and restart the song. My code is different because of the array.
Any ideas?
music = new Array(“music1.mp3”,“music2.mp3”, “music3.mp3”, “music4.mp3”,“music5.mp3”,“music6.mp3”,“music7.mp3”,“music8.mp3”,“music9.mp3”);
currenttrack = 0
function stopmysound(){
trace (“function stop sounds works!”);
slideSound.stop();
}
function changeTrack(number){
if (number >= 0 && number < music.length){
currentTrack = number;
slideSound.stop();
slideSound = new Sound();
slideSound.loadSound(“music/”+ music[number], true);
//loading bar
downloaded = slideSound.getBytesLoaded(audio);
total = slideSound.getBytesTotal(audio);
if (downloaded != total) {
textbox = "downloading song...";
// textbox is the text area
} else {
textbox = "Song Loaded";
// textbox is the text area
// The audio should start to play here
}