Could somone explain it to me?

MovieClip.prototype.changePhoto = function(d) {
this.pIndex = (this.pIndex+d)%this.pArray.length;
if (this.pIndex<0) {
this.pIndex += this.pArray.length;
}
this.onEnterFrame = fadeOut;
};

Could someone be so kind and explain this to me…
“pIndex” starts al zero (0)

and what the $&$% is “this.pArray.length”

I hope this explination will do… :wink:

[AS]
// create prototype (in this case a function that
// can be called from every movieclip, like myClip.changePhoto )
MovieClip.prototype.changePhoto = function(d) {
// % = modulo operator, which divides
// expression1 (pIndex+d) with expression 2 (pArray.length)
// and returns the remainder.
// For example: 7 % 3 would return 1.
// 7/3 = 2
// 2*3 = 6
// 7-6 = 1)
this.pIndex = (this.pIndex+d)%this.pArray.length;
// if pIndex is more than 0
if (this.pIndex<0) {
// add pArray.length to pIndex.
this.pIndex += this.pArray.length;
}
this.onEnterFrame = fadeOut;
};
[/AS]

pArray.length is the length of the array pArray. if the pArray contains two values, the length is two. if it contains five values, length is five and so on…

if you don’t call the function with a parameter, I assume pIndex will be zero at the beginning.
this will make pIndex = 1 at the beginning:
myClip.changePhoto(1);

also, see Flash help on the modulo operator: AS dictionary > Symbolic operators > % (modulo)

Thank you very much