It gets the remainder of the second number divided into the first number.
So 4%2 will return 0 because there is no remainder, but 4%3 will return 1 because there is a remainder of 1. And 10%6 will return 4 because there is a remainder of 4 when you divide 10 by 6.
So if pIndex is equal to the remainder of pIndex+d divided by the amount of items in the pArray array.
Yeah I know… I don’t know why I said “in Flash” I was just going to leave it as “is called modulo”, but I guess I ended up typing the rest there… hmm… I think I need sleep.
If I am correct (it’s 3am here, i’m a bit… uhh… beat so I could be wrong), what this does is allows the gallery to loop so that when the last image is reached and you hit next it goes back to the first image and starts over.
It says pIndex+d…and it says funcion (d) too, so wat is pIndex adding?!!
and another question…before this code it said pIndex = 0, and as you said in your last post the code said:
// make sure pIndex falls within pArray.length
so what does that really mean?! i’m bit confused andsorry if you’re sleepy
d can be one of 2 values, -1, or 1, as is shown on the back and forward buttons of the gallery.
So it could be pIndex+1 or pIndex+(-1) (essentially pIndex-1), and as with the forward button, if you keep hitting back and reach the first image, the gallery shoots back to the last image and starts in an infinite pattern like that so you can never just “stop” at the end of the gallery, it just loops.
Arrays start counting at 0, so item1 is really at place 0. So pIndex starts at 0 which is the beginning of the gallery. So pIndex is first set to 0.
[edit]my array explanation might be lacking so heres an example…
myArray = [“item 1”, “item 2”, “item 3”]
“item 1” is in place 0, “item 2” is in place 1, and “item 3” is in place 2.
d is a parameter of the function. When you call the function you supply a value of 1 or -1. 1 goes forward, -1 goes back (which is done via that whole modulo equation). You set the number when you call the function, which in the case of the photo gallery tutorial it is on the buttons, or when the left and right keyboard buttons are pressed.
It will look something like changePhoto(1) or changePhoto(-1)
hmm i have one question.Ok i have the array but i don’t use back and forward,i use pics.So when i click on a pic i want to call an item from an array and not it’s position.Instead of myArray[0] i want to have the item itself.How am i supose to that?
Well I don’t understand what you were trying to do, but congrats on fixing the problem, I really wasn’t up for trying to figure out a whole new gallery technique :hangover:
The example of the gallery we worked with here is Sbeeners Photo Gallery tutorial which can be found on kirupa.com, if you were interested (and if the link wasn’t posted here already)