PDA

View Full Version : Repeating Flying Letters



Neticus
09-01-2005, 07:32 PM
Flying Letters (http://www.dynamicdrive.com/dynamicindex10/flyletter.htm)

Hi

Please, how do I make that script keep repeating? Currently it does 1 cycle then stops until the page is revisited or refreshed. If possible, I'd like it to repeat every 9 seconds. Im not really a coder but I can follow instructions such as FIND 'code..' ADD, CHANGE etc. :)

Any help appreciated. Thanks

Twey
09-01-2005, 07:55 PM
That's some ugly code ye got thar, sonny-Jim.

<h2><span id="fly"></span></h2>

<script type="text/javascript">
window.onerror=new Function("return true");

//Flying Letters script- by Matthias (info@freejavascripts.f2s.com)
//For this script and more, visit http://www.dynamicdrive.com

//Configure message to display. Use "$" for linebreak
message = "Thanks for visiting Dynamic Drive!" // $ = taking a new line
distance = 50 // pixel(s)
speed = 100 // milliseconds
interval = 5; // Seconds to wait between running

if (!document.all)
document.write('<h2>'+message+'</h2>')

</script>

<script language="JavaScript1.2">

txt="";
num=0;
num4=0;
flyofle="";
flyofwi="";
flyofto="";

function start() {
txt="";
num=0;
num4=0;
flyofle="";
flyofwi="";
flyofto="";
stfly();
setTimeout("start()", interval * 1000);
}

function stfly() {
for(i=0;i != message.length;i++) {
if(message.charAt(i) != "$") {
txt+="<span style='position:relative;visibility:hidden;' id='n"+i+"'>"+message.charAt(i)+"<\/span>";
} else {
txt+="<br>";
}
}
fly.innerHTML=txt;
txt="";
flyofle=fly.offsetLeft;
flyofwi=fly.offsetWidth;
flyofto=fly.offsetTop;
fly2b();
}

function fly2b(){
if(num4 != message.length){
if(message.charAt(num4) != "$") {
eval("n"+num4+".style.left=flyofle-n"+num4+".offsetLeft+flyofwi/2");
eval("n"+num4+".style.top=flyofto-n"+num4+".offsetTop+distance");
eval("fly3('n"+num4+"',eval(n"+num4+".style.left.substring(0,n"+num4+".style.left.length-2)),(eval(n"+num4+".style.left.substring(0,n"+num4+".style.left.length-2))/5),eval(n"+num4+".style.top.substring(0,n"+num4+".style.top.length-2)),(eval(n"+num4+".style.top.substring(0,n"+num4+".style.top.length-2))/5))");
}
num4++;
setTimeout("fly2b()",speed);
}
}
function fly3(target,lef2,num2,top2,num3){
if((Math.floor(top2) != 0 && Math.floor(top2) != -1) || (Math.floor(lef2) != 0 && Math.floor(lef2) != -1)) {
if(eval("'"+lef2+"'").charAt(0) != '-'){
lef2=lef2-num2
} else {
lef2+=(-num2)
}
if(Math.floor(lef2) != -1) {
eval(target+".style.visibility='visible';"+target+".style.left=Math.floor(lef2)");
} else {
eval(target+".style.visibility='visible';"+target+".style.left=Math.floor(lef2+1)");
}
if(eval("'"+lef2+"'").charAt(0) != '-') {
top2=top2-num3
} else {
top2=top2+(-num3);
}
if(Math.floor(top2) != -1){
eval(target+".style.top=Math.floor(top2)");
} else {
eval(target+".style.top=Math.floor(top2+1)");
}
setTimeout("fly3('"+target+"',"+lef2+","+num2+","+top2+","+num3+")",50);
}
}

// stfly();

start();
</script>
That looks a lot better.

Neticus
09-01-2005, 10:18 PM
Thanks Twey...appreciated.

Neticus
09-07-2005, 01:28 AM
Hi all

Im thinking it would be cool if the text generated by 'flying letters' could be url clickable. Is there a way to make the text double as a link also?

Any help appreciated. Thanks

Neticus
09-08-2005, 04:18 PM
Ok, so I take it this can not be done? Ah well.

Cool script anyhow.

Thanks again,
Net.

Twey
09-08-2005, 07:50 PM
Yes, certainly. Just put the HTML in the message string.

Neticus
09-11-2005, 02:30 AM
Hmm

like you said I tried inserting html into message string. Yet all i get is the html coming up in the same way as the message :confused:
im doing:


message = "<a href=index.php>Thanks for visiting Dynamic Drive!</a>"
I suppose im inserting it wrong! any ideas please?

jscheuer1
09-11-2005, 04:58 AM
It cannot be done simply by inserting HTML because the script carves up the message string and serves it as repeating characters that are made to appear as one flying letter each. You can make the entire message a link by putting the anchor outside of the flying span:

<h2><a href="some.htm"><span id="fly"></span></a></h2>or even:

<h2><a href="some.htm" id="fly"></a></h2>It would be nice too, to add a noscript tag containing a default message and link for non javascript enabled browsers:

<noscript><h2><a href="some.htm">Thanks for visiting Dynamic Drive!</a></h2></noscript>Be sure to add your link to the non-IE section as well and while we are at it, let's add in language to make it work in opera too (additions red):

if (!document.all||window.opera)
document.write('<h2><a href="some.htm">'+message+'</a></h2>')

Neticus
09-11-2005, 04:22 PM
Thank you jscheuer1 worked a charm.

Thankyou.
Neticus