I've encountered strange behavior when using AS3's TouchEvent
s to handle multi-touch. The touch lags considerably in certain situations, but Flash's frame rate isn't affected. It's as though the touches are getting buffered and the events just aren't dispatched until several seconds after the touch.
I've uploaded a demonstration here: https://youtu.be/omkCDqljfio
I've only managed to reproduce this touch lag in the ActiveX version of Flash Player, but I've reproduced it in both Windows 10 and Windows 7. So what I have here is a C# application that's hosting my AS3 test suite, but it can also be observed if the swf is viewed in Internet Explorer.
Since my application already involves hosting the SWF in a WPF window, I've been attempting to create a solution where touch is received in C# and then communicated to the AS3. It would work perfectly but it seems my WPF window isn't receiving touch frames when the touch is on a WindowsFormsHost
. So there's another problem that I have to solve.
FlashDevelop project: https://drive.google.com/file/d/0BxC2eCzurT9rd0gzSGc4TUdQLTQ/view Visual Studio solution: https://drive.google.com/file/d/0BxC2eCzurT9rUThmRHBKWHZmbzA/view
AS3 touch events:
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
stage.addEventListener(TouchEvent.TOUCH_BEGIN, stage_touchBegin);
stage.addEventListener(TouchEvent.TOUCH_MOVE, stage_touchMove);
stage.addEventListener(TouchEvent.TOUCH_END, stage_touchEnd);
Creating the display objects that contribute to the lag, presumably because of the touch event capture phases:
for (var i:int = 0; i < 500; i++)
{
Dotter.createBGDot(_bgLayer, _shapesOn ? Shape : Sprite);
}
...
static public function createBGDot(bgLayer:Sprite, dotClass:Class):void
{
var dot:* = new dotClass();
var color:Color = new Color();
color.brightness = Math.random();
dot.graphics.beginFill(color.color);
dot.graphics.drawCircle(0, 0, Math.random() * 400 + 40);
dot.x = Math.random() * bgLayer.stage.stageWidth;
dot.y = Math.random() * bgLayer.stage.stageHeight;
bgLayer.addChild(dot);
}
I know this is sort of an unusual situation, but I appreciate any advice about how to resolve these issues.
Now that I've used Adobe Scout I think it is a rendering issue after all. The frame rate still shows 30fps because the processing time just barely manages to hit the 30fps mark. Lowering the frame rate fixes the problem.
It is still strange that the touch events would have such a long delay when the frame rate is just barely falling short, though.