Avatar billede snigeren Nybegynder
11. juli 2004 - 18:58 Der er 1 løsning

fadein+loop af sound

Hej

Jeg bruger følgende script til at hente/preloade musik i flash... men jeg har også brug for at fade musiken ind og derefter loope den uden fadeup.

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 % loaded...";
    _parent.gotoAndStop(2);
  } 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 + " % loaded...";
}

// Load a streaming sound.
lyd.preloadSound("flash/sound/cosmopolitan.mp3", true);
lyd.onSoundComplete = function() {
    this.preloadSound("flash/sound/cosmopolitan.mp3", true);
}

håber ikke det kan fylde for meget =)

men det er egentlig bare en fadein over 5-10 sekunder jeg har brug for så man ikke bare får max volume fra starten.

/Snig
Avatar billede snigeren Nybegynder
12. juli 2004 - 13:56 #1
lukker
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester