View Full Version : How to refer to a Function 1 Image() Array in Function 2?

02-24-2007, 04:58 PM
I have 2 functions. The first is an XMLhttpRequest that loads a series of images into an Image() array.

The second function has up and down arrow key listeners to activate when the up and down arrow keys are pressed.

How do I refer to the Image() array in my up/down key listener function?

(I am trying to make the up key advance the image by 1 and the down key decrement the image by one when each are pressed).

Help please!!!

You can see the live code here:


02-24-2007, 05:23 PM
When code is inside a function, as I understand it, it only lives inside of that function. If you want the second funtion to have access to it, you need to either declare the array outside of the function, then load the images inside the function, or pass the array to the second function.