Click to See Complete Forum and Search --> : Help with Image Expansion


brendandonhue
05-20-2003, 05:01 PM
In another thread, I came up with a script to expand/contract an image. Demo at
http://mywebpages.comcast.net/brendandonhue/file.html

The problem is...you can't have multiple images expand with the script. I know exactly why, and attempted a few ways at fixing it, but it didnt work.

The problem is, it references which image to use by document.images[0].
If there are multiple images in the page, they wouldnt all be document.images[0], the next one is document.images[1].
I have added another argument to my function so that you could include the image's number as a variable in the function.
It does the 1st expansion (it does the full expansion in increments of 2 pixels), but it uses SetTimeOut to repeat the expansions, and the image number argument doesnt get passed when i do the settimout.


I know...this is really confusing. Please tell me if there is anything I need to clarify on.

Much thanks.

Jona
05-20-2003, 05:15 PM
You should be able to access it like this: onMouseOver="changeImg(2, this);" onMouseOut="changeImg(-2, this);" and change all of the instances of document.images[0] to document.images[IMG]
Of course, you'll want change the function starting to this: function functionName(changeBy, IMG){

brendandonhue
05-20-2003, 05:36 PM
Thanks, but its not quite working.
Now it expands 2 pixels on mouseover and -2 onmouseout like its supposed to, but it just expands the 2 pixels and stops.
Like this:
http://mywebpages.comcast.net/brendandonhue/file.htm

Jona
05-20-2003, 05:48 PM
Change setTimeout() to setInterval()

brendandonhue
05-20-2003, 06:00 PM
Thanks for trying, but its still not working...
Maybe I should re-do it using an array to store the images or something.

Jona
05-20-2003, 06:05 PM
No, that shouldn't be needed. We are going about it the right way, I'm sure of it. We just need to figure out why it's not working for us..

brendandonhue
05-20-2003, 06:06 PM
Ok, thanks for taking the time.

Jona
05-20-2003, 06:19 PM
Well, it makes no sense to me, because it should work fine... Try changing the 50 in the setTimeout() to 500 or something..