Increment

Javascript Increment Index on event

Swiftlikeninja's picture

I am trying to figure out a way to increment an index of an array based on an event (such as left mouse click over a hit area). The code below sets everything to zero and briefly changes the appropriate index to 1 while the mouse is clicked but changes back to 0 once the mouse is released. What I want to happen is each time the index value is incremented then it stores its current value instead of switching to 0. By the end the array should be mixed numbers. Can anyone provide and assistance?

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;
   }   
}