smanetto in ASP.NET con VC# ..sono un neofita di Flash CS4 con AS3 ..per di più me ne interesso a singhiozzo (benedetta incoscienza!)..
ho fatto ("fatto" è una parola grossa!) un sito in flash (per un amico)
http://www.laspeziaroller.org
per quanto iscritto al forum HTML da tempo non ne ho mai usufruito (m'é sempre bastata la consultazione) ..ma stavolta non ne vengo a capo, nonostante abbia copiosamente attinto svarianti spunti in giro per il Web![]()
il nocciolo della questione è visualizzare una barra di progressione per il caricamento di un swf esterno(nell'esempio gare.swf, all'interno della directory dell'swf principale).. non è quello del sito, è una prova.
ecco il codice:
nella finestra output compaiono i seguenti valori:Codice PHP:import fl.controls.ProgressBar
import fl.controls.ProgressBar;
var req:URLRequest = new URLRequest("gare.swf");
var my_loader:Loader = new Loader();
my_loader.load(req);
var barra:ProgressBar = new ProgressBar();
barra.x = 100;
barra.y = 200;
barra.source = my_loader.contentLoaderInfo;
addChild(my_loader);
addChild(barra);
my_loader.contentLoaderInfo.addEventListener(Event.INIT, initListener);
function initListener (e:Event):void{
trace("Object Initialized");
}
my_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, caricamento);
function caricamento(p:ProgressEvent):void {
var percent:Number = getDecimal((p.currentTarget.bytesLoaded / p.currentTarget.bytesTotal),1);
trace(percent); //getDecimal((p.currentTarget.bytesLoaded / p.currentTarget.bytesTotal),1));
barra.scaleX = percent;
}
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completato);
function completato (e:Event):void{
removeChild(barra);
barra = null;
trace("Loading Completato");
}
function getDecimal(num:Number, pos:Number):Number{
var dec= Math.pow(10 , pos)
var arrNumber= (Math.round(num*dec))/dec
return arrNumber
}
0 0.2 0.3 0.5 0.6 0.8 0.9 1 Object Initialized Loading Completato
il mio problema è che non capisco perché non mi visualizza 'sta progressBar.. ho provato sia ad andare da 0 a 1 che da 1 a 100 modificando:
ottenendo il seguente outup:Codice PHP:var percent:Number =
Math.ceil((p.currentTarget.bytesLoaded /p.currentTarget.bytesTotal)*100);
0 16 31 46 61 76 91 100 Object Initialized Loading Completato
se commento
visualizzo la progressBar a 0Codice PHP:removeChild(barra); barra = null;
..avevo anche provato ad aggiungere l'EventListener alla progressBar anziché al loader ad impostare barra.source = my_loader; ..insomma ne ho tentate diverse![]()
per di più non dà alcun errore!![]()
..qualcuno mi aiuta?![]()

Rispondi quotando