AS3 touch events lagging and causing unwanted right-click behavior


#1

This may be a long shot, but hopefully someone can help me with this.

I’m running Windows 10 64-bit on a Dell Inspiron laptop with a 10-touch-point touchscreen. I can get touch events to fire but they’re not working the way I’d like in all cases.

A little preliminary info first. On a touchscreen Windows PC, try touching and holding on the background. A transparent white square should tween from small to large, indicating that a right-click will occur if you release that touch. Instead of releasing, add a second touch somewhere else. The square should tween from large to small and disappear. This is normal behavior, and should happen anywhere that has right-click functionality.

Now open Google Chrome (I just updated to the new version 58 but I presume any version will do). Follow the steps from before and watch the square disappear. Now, while still holding a finger down, touch again somewhere else, and keep tapping. Notice the square tweening out over and over again in the same spot despite already having disappeared. If you release your original touch it remembers the point where that touch was released and continues to tween out the square in that spot. In Chrome you can use a two-finger tap to bring up the right-click menu, and I suspect this problem occurs anywhere that has two-finger tap right-click functionality. I suspect this is a Windows bug rather than a Chrome bug.

When I test my program in FlashDevelop this same problem occurs. The program responds pretty quickly when it’s just one touch, but the events can lag considerably when there are multiple touches. I’ve tested in four environments with the following results:

FlashDevelop: White square bug and lag
Standalone Flash Player (projector); White square bug and no lag
Google Chrome: No touch events firing at all
Internet Explorer: No white square bug and no lag

So the ideal behavior seems to be what’s happening in Internet Explorer, and I’d like that to happen everywhere. I’d like to know if there’s a way to suppress the two-finger touch functionality (and just right-click functionality in general), or if there’s some other way to fix this. Here’s my code:

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TouchEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.ui.Multitouch;
	import flash.ui.MultitouchInputMode;

	/**
	 * ...
	 * @author Kyle Delaney
	 */
	[Frame(factoryClass="Preloader")]
	public class Main extends Sprite 
	{
		private static var _output_txt:TextField = new TextField();
		
		public function Main() 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}

		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			graphics.beginFill(0);
			
			graphics.drawRect( -5, -5, stage.stageWidth + 5, stage.stageHeight + 5);
			
			var tf:TextFormat = new TextFormat();
			tf.font = "Courier New";
			tf.size = "14";
			_output_txt.defaultTextFormat = tf;
			_output_txt.wordWrap = true;
			_output_txt.width = stage.stageWidth /2;
			_output_txt.height = stage.stageHeight;
			_output_txt.selectable = false;
			_output_txt.mouseEnabled = false;
			_output_txt.background = true;
			_output_txt.alpha = 0.5;
			addChild(_output_txt);
			print("init()");
			
			Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
			
			addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
			addEventListener(TouchEvent.TOUCH_BEGIN, touchBegin);
			addEventListener(TouchEvent.TOUCH_END, touchEnd);
			//addEventListener(TouchEvent.TOUCH_MOVE, touchMove);
			addEventListener(TouchEvent.TOUCH_TAP, touchTap);
		}
		
		private function touchTap(e:TouchEvent):void 
		{
			print("touchTap() " + e.touchPointID);
		}
		
		private function touchMove(e:TouchEvent):void 
		{
			print("touchMove() " + e.touchPointID);
		}
		
		private function touchEnd(e:TouchEvent):void 
		{
			print("touchEnd() " + e.touchPointID);
		}
		
		private function touchBegin(e:TouchEvent):void 
		{
			print("touchBegin() " + e.touchPointID);
		}
		
		private function mouseDown(e:MouseEvent):void 
		{
			print("mouseDown");
		}
		public static function print(str:String):void
		{
			if (_output_txt)
			{
				_output_txt.appendText(str + '\n');
				if (_output_txt.length > 10000) _output_txt.replaceText(0, 5000, "");
				_output_txt.scrollV = _output_txt.maxScrollV;
			}
		}
	}

}

Here’s the swf: DummyFlash.swf (1.8 KB)

And here’s an upload of the swf: http://www.newgrounds.com/dump/item/8eb8b87e551f48db7e0e50c66d3178ff