I am currently working on a project that involves incrementing an index of an array based on certain events, such as a left mouse click over a designated area. The code snippet provided below initializes all values to zero and briefly changes the relevant index to 1 while the mouse is clicked, but reverts back to 0 once the mouse is released. What I aim for is to have each time the index value is incremented, it saves and retains its current value instead of resetting to 0. Ultimately, I want the array to have mixed numbers. Can anyone offer some guidance or assistance with this issue? My work is set within the Quartz Composer environment utilizing the JavaScript patch.
function (__structure out) main (__structure Pos, __boolean Left, __number X,
__number Y, __number W, __number H, __number ShiftX, __number ShiftY) {
if (!_testMode) {
len = Pos.length;
Hits = new Array()
for (i = 0; i < len; i++) {
Hits[i] = 0
}
for (j = 0; j < len; j++) {
if (Pos[j][1] >= (X-(W/2)) && Pos[j][1] <= (X +(W/2)) &&
Pos[j][0] >= (Y-(H/2)) && Pos[j][0] <= (Y +(H/2)) && Left) {
Hits[j]++
}
}
result = new Object();
result.out = Hits;
return result;
}
}