Note, this hasn't been connected up to real news feeds. Any news displayed is current as of the 10th of August 2004.
A really straight forward bit of code (in the end!). This text ticker, made in flash, scrolls a line of text across the page.
It works by taking parts of a string and chopping them up, and sticking them back together again.
If you know a bit about flash, you might find the code below useful. It works in a single frame, and you only need a text box set to acccept the variable ticktext.
Having a fixed width font is important too, it looks all funny if you use a variable width font.
messages = new Array();
messages = "A major security update for the Windows XP operating system is about to become widely available.";
messages[1] = "A rocket by a team taking a low-budget stab at the Ansari X-prize has exploded in mid-air.";
function implode(array) {
var t = "";
for(key in array) {
t += " - - - - - " + array[key];
}
return t;
}
message = new String(implode(messages));
ml = message.length;
mi = 1;
md = 0;
onEnterFrame = function() {
if(md > 0) {
md--;
} else {
if(mi > ml) {
mi = 1;
}
ticktext = message.substring(mi, ml);
ticktext += message.substring(0, mi-1);
mi++;
md = 1;
}
}