| View previous topic :: View next topic |
| Author |
Message |
nin2010
Joined: 20 Apr 2008 Posts: 3
|
Posted: Sun Apr 20, 2008 3:56 pm Post subject: Mouse Over - More than two images |
|
|
Hello all. I'm sorry my first post in these forums is a question but I'll do my best to help out where I can also and hope that one of you can help me.
I have working javascript that allows my forum buttons to switch when a user mouses over them. This works great but I was thinking that being able to have 3 or 4 images load in a sequence as you mouseover would be even better.
Basically the idea is so that the text colour will change gradually from one colour to the next instead of an instant change.
The problem I am having is that it just switches to the last called image flip straight away rather than doing them in order. I've been trying to figure it out but have been unsuccessful..
The section of code giving the problem is as follows:
| Code: |
// Preload the Images in here
if (document.images) {
var flipped = new Array();
for(i=0; i< inames.length; i++) {
flipped[i] = new Image();
flipped[i].src = "images/"+inames[i]+"2.jpg";
}
}
// Preload the second image to be flipped
if (document.images) {
var flipped_again = new Array();
for(i=0; i< inames.length; i++) {
flipped_again[i] = new Image();
flipped_again[i].src = "images/"+inames[i]+"3.jpg";
}
}
// This function controls what happens when the user mouses over an image
function over(num) {
if(document.images) {
revert[num] = document.images[inames[num]].src;
document.images[inames[num]].src = flipped[num].src;
pausecomp(50);
document.images[inames[num]].src = flipped_again[num].src;
}
}
|
So you can see that it stores the original image name in the revert array to be switched back to when your mouseout. Then you flip the image name to the one stored in the flipped array , it pauses for 50ms and then it should flip to the image name in the flipped_again array.
It flips directly to the image name stored in flipped_again with the code above, if I comment out the line of code changing the image to flipped_again then it switches it to the image name stored in the flipped array.
I don't understand why it doesn't do this in sequence, any help or pointers would be appreciated...
Daragh |
|
| Back to top |
|
 |
|
|
nin2010
Joined: 20 Apr 2008 Posts: 3
|
Posted: Sun Apr 20, 2008 5:36 pm Post subject: Re: Mouse Over - More than two images |
|
|
I just realised that I can use my original code and use gif images with a little animation to gradually fade in the text colour rather than using jpgs.
So no need to fix the code now.  |
|
| Back to top |
|
 |
|