sorry about the bad title, but this is a code that takes a string, defined in an array, and converts it to the next string in the array by replacing letters one at a time. it works fine, but i want some modifications.
code:
function scroll(message_loop)
{
var messages = new Array();
messages[0] = "String1";
messages[1] = "String2";
messages[2] = "String3";
if(message_loop >= messages.length)
{
message_loop = 0;
}
var old_value = window.document.getElementById('scroll_text').innerHTML;
var new_value;
var random = Math.floor(Math.random() * messages[message_loop].length);
var change_letter = messages[message_loop].charAt(random);
if(old_value == messages[message_loop])
{
message_loop++;
setTimeout("scroll("+message_loop+")",700);
return;
}
if(change_letter == old_value.charAt(random))
{
scroll(message_loop);
return;
}
var first_part = old_value.substring(0,random);
random++;
var last_part = old_value.substring(random,messages[message_loop].length);
var new_value = first_part + change_letter + last_part;
window.document.getElementById('scroll_text').innerHTML = new_value;
setTimeout("scroll("+message_loop+")",50);
}
i was wondering if there is a way to make it so that each string has its own wait time till the next string starts appearing, so that they dont all go away after the single set time.
also, i was wondering if there is a way to make it so that when it appears inline, it doesn't effect the words around it by pushing them around, because the length is constantly changing.
the last thing is that when one of the strings is just a space, ie stops completely when it reaches that string and doesn't go on. in ff its fine, and goes on to the next one.
thanks for any help, and forgive me for the horrible thread title.
billy