Home > Reference > Widgets > Media > MultiTouch

MultiTouch

The MultiTouch widget is designed to work with multi-touch devices. The Moto Development Group multi-touch table is currently supported, along with their multi-touch simulator (available on the NETLab Toolkit downloads page). The widget receives touch events from the table or simulator. These events can be processed in Flash in two ways. If the outputTarget parameter is set to the instance name of a _root level movieClip, that clip will have a multiTouch(theX, theY) function invoked every time a touch event occurs. As an alternative, an event listener can be set up to process touch events as they arrive. See below for code examples.

Note: When using the multi-touch simulator, start it by double clicking on the “motomultitouchsimulator.jar” Java file. Once open, select the “Open Port” button first using the default port number 2000.

On-screen Features

  • X and Y: Shows the x,y values received from the multi-touch table or simulator.
  • OUT: Shows the instance name of the clip(s) targeted for dragging on touch events as specified in the touchClips parameter.

Parameters

  • INVISIBLE: if set to “yes”, the widget will disappear when the Flash movie is run
  • TOUCHCLIPS: the instance name of a movieClip or movieClips – if more than one clip is listed, separate them by commas – e.g. “clipa,clipb,clipc”. Each clip listed will be moved by a touch if the touch is inside the clip’s boundaries. The default is “none”, where no clips are affected.

touchClips Explanation

If you set the touchClips parameter to the instance name of one or more movieClips separated by commas, these clips will be affected by touches. If a touch occurs within the shape of a movieClip, the clip will be dragged around by subsequent touches. Currently, the widget does not yet support multiple objects being dragged simultaneously.

getTouches(x, y, id) Explanation

If you want to handle touches received by the MultiTouch widgets with your own code, you can create a function that will receive touches from the widget. First, put the MultiTouch widget on the stage and give it an instance name in the Properties inspector (e.g. “touch”). Then in the first frame of the main timeline, add the following code.

// assumes the MultiTouch widget has an instance name of "touch"
touch.getTouches = myTouches;

function myTouches(x,y,id) {
	trace("mytouches " + id  + " x:" + x + " y:" + y);
}

The function you set up to receive touch events will get three parameters:

x – the x coordinate of a touch

y – the x coordinate of a touch

id – the instance name of the MultiTouch widget sending the touch events


Last modified March 24th, 2011