PDA

View Full Version : Problem using horizontal text scroller


ancahe
07-29-2008, 08:28 AM
Hello!

I am getting desperate at trying to setup up a horizontal scroller :confused:. I don't know where I did the mistake.
The flash should load an external xml (which actually works fine) and put the news items on screen. That's the part the doesn't work.
I got the code from here and tried to change some params.

Second, the scroller shouldn't scroll over the company logo. How can I do that?


Maybe someone can help me..

Here's the code
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
caption = [];
time = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
caption[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
time[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;

mcText._txt.text = mcText._txt.text + caption[i] + " // ";
}
} else {
content = "file not loaded!";
}
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://ticker.cahen.ch/news.xml?uniqueID=" + new Date().getTime());


var resetPos:Number = (mcText._txt._x * -1) + 250;
var endOfText= mcText._txt._x - (mcText._txt.textWidth+500);
mcText._pos.text = endOfText + " = " + mcText._txt._x +" - "+(mcText._txt.textWidth+500);
function scroller() {
mcText._txt._width = mcText._txt.textWidth;
mcText._txt.multiline = false;
mcText._txt.autoSize = "left";
mcText.onEnterFrame = function() {
mcText._txt._x -= 10;

if (mcText._txt._x < endOfText) {
mcText._txt._x = resetPos;
delete this["onEnterFrame"];
scroller();
}
}
}
scroller();

Thanks a lot!