Visualizzazione dei risultati da 1 a 2 su 2

Discussione: preload MP3 esterno

  1. #1

    preload MP3 esterno

    Nella guia di flash ho trovato questo codice actionscript.

    // Create a new Sound object to play the sound.
    var songTrack:Sound = new Sound();

    // Create the polling function that tracks download progress.
    // This is the function that is "polled." It checks
    // the downloading progress of the Sound object passed as a reference.
    function checkProgress (soundObj:Object):Void {
    var numBytesLoaded:Number = soundObj.getBytesLoaded();
    var numBytesTotal:Number = soundObj.getBytesTotal();
    var numPercentLoaded:Number = Math.floor(numBytesLoaded / numBytesTotal * 100);
    if (!isNaN(numPercentLoaded)) {
    trace(numPercentLoaded + "% loaded.");
    }
    };

    // When the file has finished loading, clear the interval polling.
    songTrack.onLoad = function ():Void {
    trace("Complete");
    clearInterval(poll);
    };
    // Load streaming MP3 file and start calling checkProgress(),
    songTrack.loadSound("http://mp3_path", true);
    var poll:Number = setInterval(checkProgress, 100, songTrack);


    Come faccio per creare una variabile da richiamare in una casella di testo dinamica che mi dia la percentuale di avanzamento.

    Io ho provato ad aggiungere al codice:
    progresso = numPercentLoaded + "%"; e dare progresso come variabile da richiamare dalla casella di testo dinamica, ma in preview poi appare "undefined %".

  2. #2
    codice:
    var songTrack:Sound = new Sound();
    
    
    function checkProgress (soundObj:Object):Void {
       var numBytesLoaded:Number = soundObj.getBytesLoaded();
       var numBytesTotal:Number = soundObj.getBytesTotal();
       var numPercentLoaded:Number = Math.floor(numBytesLoaded / numBytesTotal * 100);
      if (!isNaN(numPercentLoaded)) {
          
         /* Questa trace la vedi correttamente ??
         se SI allora forse non hai scritto il nome di istanza o variabile
         al tuo campo dinamico
         */
          trace(numPercentLoaded + "% loaded."); 
         campo_progresso.text= numPercentLoaded + "% loaded."
      }
    };
    
    songTrack.onLoad = function ():Void {
         trace("Complete");
        clearInterval(poll);
    };
    
    songTrack.loadSound("http://mp3_path", true);
    
    var poll:Number = setInterval(checkProgress, 100, songTrack);

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.