Results 1 to 3 of 3

Thread: Flying Butterfly script - how do you dismiss after x seconds?

  1. #1
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Flying Butterfly script - how do you dismiss after x seconds?

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Here is the init function from the script:

    Code:
    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):

    Code:
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you so much! I will try.

    Jen

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •