SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot Da Mouse's Avatar
    Join Date
    Aug 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fairly large image swapping script

    can you see whats wrong with the script I attached it has multi -level arrays and such, i couldn't get it to run smoothly
    Attached Files Attached Files
    I am DaMouse
    Nobody can beat me so long as I'm stubborn -DaMouse
    Squeak

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about this?
    Code:
    <script language="javascript" type="text/javascript" >
    <!--
    function preload() {
    	var imgRoot = 'images/';
    	var ext = '.bmp';
    	var imgNames = ['00','01','10','11','20','21','30','31','40','41','50','51'];
    	var imgs = new Array();
    	var count = 0;
    	for (var i=0; i<imgNames.length; i++) {
    		imgs[count] = new Array();
    		imgs[count][0] = new Image();
    		imgs[count][0].src = imgRoot + imgNames[i] + ext;
    		imgs[count][1] = new Image();
    		imgs[count][1].src = imgRoot + imgNames[++i] + ext;
    		count++;
    		}
    	window.rImages = imgs;
    	}
    
    function rollover(img, inout) {
    	img.src = rImages[img.id][inout].src;
    	}
    //-->
    </script>
    
    <!-- code code code -->
    
    <body onload="preload();">
    
    <!-- code code code -->
    
    <img src="images/00.bmp" onmouseover="rollover(this,1)" onmouseout="rollover(this,0)" alt="Home" id="0" name="0" />
    <img src="images/10.bmp" onmouseover="rollover(this,1)" onmouseout="rollover(this,0)" alt="Contacts" id="1" name="1" />
    <img src="images/20.bmp" onmouseover="rollover(this,1)" onmouseout="rollover(this,0)" alt="Projects" id="2" name="2" />
    <img src="images/30.bmp" onmouseover="rollover(this,1)" onmouseout="rollover(this,0)" alt="Files" id="3" name="3" />
    <img src="images/40.bmp" onmouseover="rollover(this,1)" onmouseout="rollover(this,0)" alt="Forum" id="4" name="4" />
    <img src="images/50.bmp" onmouseover="rollover(this,1)" onmouseout="rollover(this,0)" alt="Links" id="5" name="5" />
    But, I must ask, WHY are you using BMPs instead of GIFs or PNGs?
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Zealot Da Mouse's Avatar
    Join Date
    Aug 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The bmps will eventuall become jpegs
    I am DaMouse
    Nobody can beat me so long as I'm stubborn -DaMouse
    Squeak

  4. #4
    SitePoint Zealot Da Mouse's Avatar
    Join Date
    Aug 2002
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the script worked perfectly with a small bit of mouse magic
    I am DaMouse
    Nobody can beat me so long as I'm stubborn -DaMouse
    Squeak


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
  •