seengee
06-08-2005, 04:13 PM
i'm using a tutorial of Kenny bellews site for "How to Build a Preloader for Dynamically Loaded MP3's"
I have followed his script but it doesnt work the first time that the swf is loaded, the preloader works fine but the mp3 never starts, as soon as i refresh the page and hit play again the mp3 plays fine. So, obviously the MP3 is being preloaded but for some reason never plays..
the script:
mySound = new Sound(this);
//mySound.attachSound("mySound01");
mySoundVolume = 100;
mySound.setVolume(mySoundVolume);
this.onLoad = function() {
mySoundLoading = 0;
_root.loadBar._xscale = mySoundLoading;
};
//END onLoad
this.onEnterFrame = function() {
mySoundBytesTotal = _root.mySound.getBytesTotal();
mySoundBytesLoaded = _root.mySound.getBytesLoaded();
if (preloadNow == 1 && mySoundBytesLoaded>0) {
mySoundLoading = Math.round((mySoundBytesLoaded/mySoundBytesTotal)*100);
_root.percentLoadedText = mySoundLoading+"%";
_root.loadBar._xscale = mySoundLoading;
trace(mySoundLoading);
if (mySoundLoading == 100) {
preloadNow = 0;
_root.mySound.start();
}
}
};
and on a button:
on (press) {
if (playing != true) {
playing = true;
preloadNow = 1;
_root.mySound.loadSound("audio/my_clip.mp3", false);
}
_root.mySound.onSoundComplete = function() {
playing = false;
};
}
Help !!!
Thanks.
I have followed his script but it doesnt work the first time that the swf is loaded, the preloader works fine but the mp3 never starts, as soon as i refresh the page and hit play again the mp3 plays fine. So, obviously the MP3 is being preloaded but for some reason never plays..
the script:
mySound = new Sound(this);
//mySound.attachSound("mySound01");
mySoundVolume = 100;
mySound.setVolume(mySoundVolume);
this.onLoad = function() {
mySoundLoading = 0;
_root.loadBar._xscale = mySoundLoading;
};
//END onLoad
this.onEnterFrame = function() {
mySoundBytesTotal = _root.mySound.getBytesTotal();
mySoundBytesLoaded = _root.mySound.getBytesLoaded();
if (preloadNow == 1 && mySoundBytesLoaded>0) {
mySoundLoading = Math.round((mySoundBytesLoaded/mySoundBytesTotal)*100);
_root.percentLoadedText = mySoundLoading+"%";
_root.loadBar._xscale = mySoundLoading;
trace(mySoundLoading);
if (mySoundLoading == 100) {
preloadNow = 0;
_root.mySound.start();
}
}
};
and on a button:
on (press) {
if (playing != true) {
playing = true;
preloadNow = 1;
_root.mySound.loadSound("audio/my_clip.mp3", false);
}
_root.mySound.onSoundComplete = function() {
playing = false;
};
}
Help !!!
Thanks.