Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Fade one image to another

  1. #1
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default Fade one image to another

    I need a script to fade one image to another and not flicker in FireFox. Any ideas?
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Have you tried this script

  3. #3
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Actually, I have but I don't need a slideshow, just fading one image to another.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    what about tweaking the technique used here so that it can serve your purpose.

  5. #5
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    I want to fade from one image to another, not just for one image.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  6. #6
    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

    I've had this lying around for awhile:

    http://home.comcast.net/~jscheuer1/s...controlled.htm

    Check out the bottom most image.
    - John
    ________________________

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

  7. #7
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Yep, that's the effect that I want. But I don't know what function it is in your code...
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  8. #8
    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

    Well the entire script is used and BTW, this isn't the standard Ultimate Fade In script. The particular code for that last image is:

    HTML Code:
    <div style="position:relative;z-index:10000;width:140px;" onmouseover="switchFade(3,2)" onmouseout="switchFade(0,2)"><script type="text/javascript">
    //new fadeshow(IMAGES_ARRAY_NAME, slideshow_width, slideshow_height, borderwidth, delay, pause (0=no, 1=yes), optionalRandomOrder)
    new fadeshow(fadeimages2, 140, 225, 0, 100, 1)
    </script></div>
    What you are most concerned with are the mouse events. The script initializes the 'show' which is then controlled by the mouse events. I'll break one of those mouse events down:

    Code:
    onmouseover="switchFade(3,2)"
    The red 3 is the image associated with the array entry [3] for this show which is using the fadeimages2 array as you can see in the script call. That means photo9.jpg:

    Code:
    fadeimages2[3]=["photo9.jpg", "", ""] //plain image syntax
    The green 2 means that it is the 3rd instance of a show on the page. Instances are numbered from 0 to whatever and because there are two other shows before it (0 and 1), this instance is 2.

    Basically what function switchFade(iNum, instance) does is switch to and fade in the image number to the show instance.
    - John
    ________________________

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

  9. #9
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    When I tested your script, the page just flickered (black to white and black again).

    I've found another script that lets me blend images (shorter version/no slideshow) but it flickers. Anyone know why?
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  10. #10
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <!-- TWO STEPS TO INSTALL FADING ROLLOVER:
    
      1.  Copy the coding into the HEAD of your HTML document
      2.  Add the last code into the BODY of your HTML document  -->
    
    <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->
    
    <SCRIPT LANGUAGE="JavaScript">
    
    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->
    
    <!-- Begin
    var maximages =6; // how many fade images do you have?
    var fadespeed = 300; // fade frame time in milliseconds;  125 = 125 ms
    
    var fadeintimer;
    var fadeouttimer;
    var fadeincount = 0;
    var fadeoutcount = maximages-1;
    var fadearray = new Array(maximages);  // enter all the fade images here
    // the first item should be 0, then numbered through 1 less than your maximages
    
    fadearray[0] = "http://javascript.internet.com/img/fading-rollover/fade00.jpg";
    fadearray[1] = "http://javascript.internet.com/img/fading-rollover/fade01.jpg";
    fadearray[2] = "http://javascript.internet.com/img/fading-rollover/fade02.jpg";
    fadearray[3] = "http://javascript.internet.com/img/fading-rollover/fade03.jpg";
    fadearray[4] = "http://javascript.internet.com/img/fading-rollover/fade04.jpg";
    fadearray[5] = "http://javascript.internet.com/img/fading-rollover/fade05.jpg";
    
    for (var i = 0; i < maximages; i++) {
    eval('pic' + i + ' = new Image();');
    eval('pic' + i + '.src = fadearray[i];'); // preloads fade images
    }
    function fade_in() {
    clearTimeout(fadeouttimer);
    document.images['fade-pic'].src = fadearray[fadeincount];
    if (fadeincount != maximages-1) {
    fadeincount++;
    fadeintimer = setTimeout('fade_in()', fadespeed);
    }
    else {
    clearTimeout(fadeintimer);
    fadeincount = 0;
       }
    }
    function fade_out() {
    clearTimeout(fadeintimer);
    document.images['fade-pic'].src = fadearray[fadeoutcount];
    if (fadeoutcount != 0) {
    fadeoutcount--;
    fadeouttimer = setTimeout('fade_out()', fadespeed);
    }
    else {
    clearTimeout(fadeouttimer);
    fadeoutcount = maximages-1;
       }
    }
    //  End -->
    </script>
    </HEAD>
    
    <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->
    
    <BODY>
    
    <center>
    <img src="http://javascript.internet.com/img/fading-rollover/icontop.gif" border=0><br>
    <img name="fade-pic" height=56 width=300 border=0 src="http://javascript.internet.com/img/fading-rollover/fade00.jpg"><br>
    <img src="http://javascript.internet.com/img/fading-rollover/iconbtm.gif" border=0><br></a>
    </center>
    
    <p><center>
    <font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
    by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
    </center><p>
    
    <!-- Script Size:  2.49 KB -->
    <script type="text/javascript">
    setTimeout('fade_in()',1000);
    </script>
    </body>
    </html>

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
  •