From 725ae8dcf06aede88fc3dd3e8d7d9efa7eae6cba Mon Sep 17 00:00:00 2001 From: Chris Speciale Date: Wed, 10 Jul 2024 10:42:33 -0400 Subject: [PATCH] Touch: Replace Vector with Array --- src/starling/events/EventDispatcher.hx | 2 +- src/starling/events/Touch.hx | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/starling/events/EventDispatcher.hx b/src/starling/events/EventDispatcher.hx index af8d35a3..f7c80782 100644 --- a/src/starling/events/EventDispatcher.hx +++ b/src/starling/events/EventDispatcher.hx @@ -84,7 +84,7 @@ class EventDispatcher { if (index != -1) { if (__eventStack.indexOf(type) == -1) { - listeners.removeAt(index); + listeners.splice(index, 1); } else { var restListeners:Array = listeners.slice(0, index); diff --git a/src/starling/events/Touch.hx b/src/starling/events/Touch.hx index caffb9d7..224a4ccd 100644 --- a/src/starling/events/Touch.hx +++ b/src/starling/events/Touch.hx @@ -12,7 +12,6 @@ package starling.events; import openfl.geom.Matrix; import openfl.geom.Point; -import openfl.Vector; import starling.display.DisplayObject; import starling.utils.Pool; @@ -54,7 +53,7 @@ class Touch @:noCompletion private var __width:Float; @:noCompletion private var __height:Float; @:noCompletion private var __cancelled:Bool; - @:noCompletion private var __bubbleChain:Vector; + @:noCompletion private var __bubbleChain:Array; /** Helper object. */ private static var sHelperPoint:Point = new Point(); @@ -92,7 +91,7 @@ class Touch __tapCount = 0; __phase = TouchPhase.HOVER; __pressure = __width = __height = 1.0; - __bubbleChain = new Vector(); + __bubbleChain = new Array(); __timestamp = __startTimestamp = -1; } @@ -204,7 +203,12 @@ class Touch var length:Int = 1; var element:DisplayObject = __target; - __bubbleChain.length = 1; + #if (haxe_ver >= 4.0) + __bubbleChain.resize(1); + #else + ArrayUtil.resize(__bubbleChain, 1); + #end + __bubbleChain[0] = element; while ((element = element.parent) != null) @@ -212,7 +216,11 @@ class Touch } else { - __bubbleChain.length = 0; + #if (haxe_ver >= 4.0) + __bubbleChain.resize(0); + #else + ArrayUtil.resize(__bubbleChain, 0); + #end } } @@ -371,9 +379,9 @@ class Touch } /** @private */ - @:allow(starling) private var bubbleChain(get, never):Vector; - private function get_bubbleChain():Vector + @:allow(starling) private var bubbleChain(get, never):Array; + private function get_bubbleChain():Array { - return __bubbleChain.concat(); + return __bubbleChain.copy(); } } \ No newline at end of file