what is the best way to pass a no static variable, in a callback, inside a loop ?? Ex: How to (fixing) a dynamic variable in a loop, and inject it into a CallBack
for (var i = 0, R = 0, C = 0; i < ItemPage.length; i++, C++) {
$image.showPicture(PID++, 'M_Item_ItemSlot_Shader', 0, this.d2d2d2[0] + (this.ITDxy[0] * C), this.d2d2d2[1] + (this.ITDxy[1] * R), 100, 100, 255, 0);
$image.setPictureTrigger(PID - 1, "Mouse Out", function(pictureId) {
that.HoverOutItem(pictureId);
});
$image.setPictureTrigger(PID - 1, "Left Click", function(pictureId, i) {
that.ClickItem(pictureId, i);
}); // i whant pass i in this callback *****
if ((i + 1) % 4 === 0) {
C = -1, R++
}
}
in this example if i pass i
, its take only the i
valur of the end loop.
How i can give static value to i
and pass in the callback ?