Ciao a tutti,
premetto che non sono un esperto di actionscript ma per lavoro devo realizzare un semplice news ticker a scorrimento orizzontale su una sola riga che prelevi il testo da un file .xml o .txt esterno..e fin quì devo dire che, anche grazie alle altre discussioni e ai forum, non ci sono problemi. L'swf finale farà parte di un video informativo per un ufficio (quindi non dovrà andare online) e siccome il file .txt o .xml verrà aggiornato di continuo, la mia esigenza è che il file venga ricaricato ad ogni fine scorrimento senza dover far ripartire l'swf per poter leggere le ultime modifiche. Sapreste indirizzarmi o darmi una mano?
Per comodità e per evitare perdite di tempo vi incollo il codice che ho utilizzato:
questo al primo frame:
Codice PHP:
stop();
var xmlFile:String = new String("news.xml");
var parsed:Array = new Array();
var parser:XML = new XML();
parser.ignoreWhite = true;
parser.onLoad = function(ok) {
if (this.loaded) {
var temp = this.firstChild.childNodes;
for (var i = 0; i<temp.length; i++) {
parsed.push({date:temp[i].childNodes[0].firstChild.toString(), itle:temp[i].childNodes[1].firstChild.toString()});
if(i>=temp.length-1) gotoAndStop(2);
}
} else {
trace("Impossibile aprire "+xmlFile);
}
};
parser.load(xmlFile);
e questo al secondo frame (dove su un altro livello è presente il mc "newsticker" con il campo di testo dinamico e la maschera):
Codice PHP:
stop();
newsticker.testo.autoSize = "left";
newsticker.testo.html = true;
for (var k = 0; k<parsed.length; k++) {
newsticker.testo.htmlText += "[url='"+parsed[k].url+"']"+parsed[k].date+" "+parsed[k].title+"[/url] - ";
}
MovieClip.prototype.animate = function() {
var limit = this.mask._width;
var end = (this.testo._width)*-1;
this.testo._x = limit;
this.t = new mx.transitions.Tween(this.testo, "_x", mx.transitions.easing.None.easeNone, limit, end, this.testo._width/20, true);
this.t.onMotionFinished = this.t.start;
};
newsticker.animate();
Spero mi possiate dare una mano e vi ringrazio anticipatamente per la disponibilità.
Ciao
Diazapam