Hvordan stopper den efter hver sang?
Hej...Jeg har en player, hvor den har følgende kode:
function loadAndPlay (some_cb) {
holderMC.lyd.stop();
loadMovie ("sound/"+some_cb.getSelectedItem().data+".swf", holderMC);
holderMC.lyd.start (0, 999);
}
function afspil () {
if (!pavs) {
holderMC.lyd.start (0, 999);
} else
holderMC.lyd.start (p, 999);
pavs = 0;
}
function pause () {
p = holderMc.lyd.position/1000;
pavs = 1;
holderMC.lyd.stop();
}
function sluk () {
pavs = 0;
holderMC.lyd.stop();
}
Hver track har en swf for sig selv og hedder track01.swk , track02.swf osv. osv.. med koden:
var mainTimeline = this;
/*
* Method: Sound.checkLoadProgress()
* Desc: Checks progress of a load().
* Called only by preload(). Reports download progress
* by invoking a custom Sound.onBytesLoaded() handler.
*/
Sound.prototype.checkLoadProgress = function () {
// Check how many kilobytes have loaded.
var kbLoaded = Math.floor(this.getBytesLoaded()/1024);
// Check the size of the file loading, in kilobytes.
var kbTotal = Math.floor(this.getBytesTotal()/1024);
// Calculate the percent complete.
var percentDone = isNaN(Math.floor(kbLoaded/kbTotal * 100)) ?
0 : Math.floor(kbLoaded/kbTotal * 100);
// Execute the onBytesLoaded() callback, which
// typically would display load progress.
this.onBytesLoaded(this.getBytesLoaded(),
this.getBytesTotal(),
kbLoaded,
kbTotal,
percentDone);
}
/*
* Method: Sound.clearLoadCheck()
* Desc: Cancels an interval calling checkLoadProgress().
*/
Sound.prototype.clearLoadCheck = function () {
// If there is a load interval for this Sound object...
if (this.loaderID) {
// ...stop calling it.
clearInterval(this.loaderID);
}
}
/*
* Method: Sound.preloadSound()
* Desc: Begins the download of a sound file and executes
* checkLoadProgress() every 200ms until the file has loaded.
* Parameters are the same as Sound.loadSound().
*/
Sound.prototype.preloadSound = function (url, isStreaming) {
// Always stop any previous preload before proceeding.
this.clearLoadCheck();
// Call checkLoadProgress() every 200 milliseconds.
this.loaderID = setInterval(this, "checkLoadProgress", 200);
// Load the Sound file.
this.loadSound(url, isStreaming);
}
// =================
// Usage
// =================
// Create a sound object.
lyd = new Sound();
// Assign an onLoad() callback.
lyd.onLoad = function (success) {
// Cancel the preload interval (REQUIRED!).
this.clearLoadCheck();
// If the load was successful...
if (success) {
// ...use the new Sound. For example, if the loaded
// sound is an event sound, we can start it like this:
// this.start();
mainTimeline.loadMsg_txt.text = "100 %";
_parent.playing=true;
} else {
// ...otherwise, perform failure operations.
mainTimeline.loadMsg_txt.text = "Load failed.";
}
}
// Assign an onBytesLoaded() callback. This is where each
// individual Sound object can decide what to do
// with the preload information.
lyd.onBytesLoaded = function (bytesLoaded, bytesTotal, kbLoaded, kbTotal, percentLoaded) {
mainTimeline.loadMsg_txt.text = percentLoaded + " % nede";
}
// Load a streaming sound.
lyd.preloadSound("sound/ftc.mp3", true);
lyd.onSoundComplete = function() {
this.preloadSound("sound/ftc.mp3", true);
}
Hvordan får jeg playeren til at stoppe efter nummeret er færdig...???? Iøjeblikket går den på uendeligt loop
