JavaScript Version of foreach (Touch touch in Input.touches)

Hey guys, I’ve been having some trouble with touch buttons, I can get them to work fine for C#, but I have a script that I’ve only been able to figure out in JavaScript and I need to touch a button to run it, I tried using my usual touch script and a bunch of other different methods after researching this for hours but I can’t find a JavaScript version.

So what I’m trying to do is turn the code bellow into a JavaScript friendly code:

#pragma strict

 

import System.IO;
import System;

 

public var moveThisButton : GUITexture;

function Update()

{
foreach (Touch touch in Input.touches) 
{

if (moveThisButton.HitTest (touch.position)) 
{
//Do The JavaScript Stuff
}
}
}

I think my public var GUITexture is right, but I’m not sure, so if it’s wrong too, please feel free to correct that too.

Thanks all!

Have you tried:

for (var touch: Touch in Input.touches) {
   // Do whatever...
}

From the docs here.