Devo realizzare un countdown in flash, però l'ora deve essere
quella del server e non quella locale del pc, in modo che sia
indicato la stessa scadenza a prescindere dalla impostazioni del pc.
Ho utilizzato questo script trovato in rete
lo script iniziale prendeva come ora corrente l'ora del pc sul quale gira il flashcodice://currentDate = new Date(); currentDate = new Date(_root.anno_corrente, _root.mese_corrente-1, _root.giorno_corrente, _root.ora_corrente, _root.min_corrente, _root.sec_corrente); thisYear = currentDate.getFullYear(); scadenza.text = "Scadenza: "+_root.giorno+"/"+_root.mese+"/"+_root.anno+" ore "+_root.ore+"."+_root.minuti; eventDate = new Date(_root.anno, _root.mese-1, _root.giorno, _root.ore, _root.minuti); eventMillisecs = eventDate.getTime(); counter.onEnterFrame = function() { //currentDate = new Date(); currentDate = new Date(_root.anno_corrente, _root.mese_corrente-1, _root.giorno_corrente, _root.ora_corrente, _root.min_corrente, _root.sec_corrente); currentMillisecs = currentDate.getTime(); this.msecs = eventMillisecs-currentMillisecs; if (this.msecs<=0) { play(); return; } trace(this.hours); this.secs = Math.floor(this.msecs/1000); this.mins = Math.floor(this.secs/60); this.hours = Math.floor(this.mins/60); this.days = Math.floor(this.hours/24); this.msecs = String(this.msecs%1000); this.secs = String(this.secs%60); this.mins = String(this.mins%60); this.hours = String(this.hours%24); this.days = String(this.days); while (this.msecs.length<3) { this.msecs = "0"+this.msecs; } if (this.secs.length<2) { this.secs = "0"+this.secs; } if (this.mins.length<2) { this.mins = "0"+this.mins; } if (this.hours.length<2) { this.hours = "0"+this.hours; } while (this.days.length<3) { this.days = "0"+this.days; } for (movie in this) { if (this[movie]._parent == this) { this[movie].evaluateFrameFrom(this); } } }; MovieClip.prototype.evaluateFrameFrom = function(variableClip) { var nameArray = this._name.split("_"); var numberSet = variableClip[nameArray[0]]; var character = Number(nameArray[1]); var frame = 1+Number(numberSet.charAt(character)); if (this._currentframe != frame) { this.gotoAndStop(frame); } };
mentre in questo modo gli ho passato l'ora del servercodice:currentDate = new Date();
estratta in aso e passata con flashvar
la cosa funziona, in quanto l'ora viene passata e il countdowncodice:currentDate = new Date(_root.anno_corrente, _root.mese_corrente-1, _root.giorno_corrente, _root.ora_corrente, _root.min_corrente, _root.sec_corrente);
indicara il tempo rimanente prendendo l'ora dal server ma è fissa,
ovvero non funziona più il countdown.
Solo se aggiorno la pagina, e flahvar invia l'ora aggiornata,
si aggiorna anche il countdown ma non conta più all'indietro come
faceva prima.
Immagino che il motivo sia perchè in questo modo l'ora attuale non è
più variabile come con new Date() bensì diventa un valore fisso passato da asp.
Come posso ovviare a questo problema?
grazie
luca

Rispondi quotando