PDA

View Full Version : Flying Butterfly script - how do you dismiss after x seconds?



JRizio
03-07-2007, 04:49 PM
Script: Flying Butterfly script
http://www.dynamicdrive.com/dynamicindex4/butterfly.htm


Hello:

I would like to use the butterfly script on an intranet to float two different small graphics on the page and then disappear.

How do I get them to disappear? I don't want the user to have to click on them; rather I'd like them to disappear after five or ten seconds. I tried C&P'ing the dismissafter script segment from the cupid script into the HTML page with the butterfly script into a few different places, but it did not work.

Please advise.

Thank you!

Jen

jscheuer1
03-07-2007, 10:20 PM
Here is the init function from the script:


function init(){
wind_w=getwindowwidth();
wind_h=getwindowheight();
for(i=0; i<floatimages.length; i++){
IDs[i]=getid('pic'+i);
if(NS4){
IDs[i].W=IDs[i].document.images["p"+i].width;
IDs[i].H=IDs[i].document.images["p"+i].height;
}
if(NS6 || IE4){
IDs[i].W=document.images["p"+i].width;
IDs[i].H=document.images["p"+i].height;
}
getnewprops(i);
moveidto(i , Math.floor(Math.random()*(wind_w-IDs[i].W)), Math.floor(Math.random()*(wind_h-IDs[i].H)));
if(NS4)IDs[i].visibility = "show";
if(IE4 || NS6)IDs[i].style.visibility = "visible";
startfly=setInterval('moveimage('+i+')',Math.floor(Math.random()*100)+100);
}}

Just add to it like so (at the bottom, red):


function init(){
wind_w=getwindowwidth();
wind_h=getwindowheight();
for(i=0; i<floatimages.length; i++){
IDs[i]=getid('pic'+i);
if(NS4){
IDs[i].W=IDs[i].document.images["p"+i].width;
IDs[i].H=IDs[i].document.images["p"+i].height;
}
if(NS6 || IE4){
IDs[i].W=document.images["p"+i].width;
IDs[i].H=document.images["p"+i].height;
}
getnewprops(i);
moveidto(i , Math.floor(Math.random()*(wind_w-IDs[i].W)), Math.floor(Math.random()*(wind_h-IDs[i].H)));
if(NS4)IDs[i].visibility = "show";
if(IE4 || NS6)IDs[i].style.visibility = "visible";
startfly=setInterval('moveimage('+i+')',Math.floor(Math.random()*100)+100);
}setTimeout("hidebutterfly()", 5000);}

The 5000 is milliseconds or 5 seconds. Adjust as desired.

JRizio
03-08-2007, 01:36 PM
Thank you so much! I will try.

Jen