Most of the applications I develop are targetting Windows and use touchscreens or touchfoils for input.
Using OpenFL, I’ve not been able to get touch working under Windows, fully.
I’m able to register a TOUCH_BEGIN event, however the stage coordinates I’m receiving from the event are always 0, 0.
A standard MOUSE_DOWN event on the same object registers the correct stage coordinates.
Example code:
class Main extends Sprite
{
public function new()
{
super();
var bitmap:Bitmap = new Bitmap(new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xFF0000));
addChild(bitmap);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler);
stage.addEventListener(TouchEvent.TOUCH_BEGIN, touchHandler);
}
private function touchHandler(e:TouchEvent):Void
{
trace("Touch begin", e.stageX, e.stageY);
}
private function mouseHandler(e:MouseEvent):Void
{
trace("Mouse down", e.stageX, e.stageY);
}
}
Output:
Main.hx:42: Touch begin,0,0
Main.hx:47: Mouse down,236,553