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 %".