Fixed and slightly improved gesture reset

This commit is contained in:
Pavel fljot 2012-07-02 22:33:50 +03:00
parent 09c35a5d97
commit 039a7d79f4

View file

@ -21,8 +21,7 @@ package org.gestouch.core
protected var _gesturesMap:Dictionary = new Dictionary(true); protected var _gesturesMap:Dictionary = new Dictionary(true);
protected var _gesturesForTouchMap:Dictionary = new Dictionary(); protected var _gesturesForTouchMap:Dictionary = new Dictionary();
protected var _gesturesForTargetMap:Dictionary = new Dictionary(true); protected var _gesturesForTargetMap:Dictionary = new Dictionary(true);
protected var _dirtyGestures:Vector.<Gesture> = new Vector.<Gesture>(); protected var _dirtyGesturesCount:uint = 0;
protected var _dirtyGesturesLength:uint = 0;
protected var _dirtyGesturesMap:Dictionary = new Dictionary(true); protected var _dirtyGesturesMap:Dictionary = new Dictionary(true);
protected var _stage:Stage; protected var _stage:Stage;
@ -53,12 +52,11 @@ package org.gestouch.core
protected function resetDirtyGestures():void protected function resetDirtyGestures():void
{ {
for each (var gesture:Gesture in _dirtyGestures) for (var gesture:* in _dirtyGesturesMap)
{ {
gesture.reset(); (gesture as Gesture).reset();
} }
_dirtyGestures.length = 0; _dirtyGesturesCount = 0;
_dirtyGesturesLength = 0;
_dirtyGesturesMap = new Dictionary(true); _dirtyGesturesMap = new Dictionary(true);
_frameTickerShape.removeEventListener(Event.ENTER_FRAME, enterFrameHandler); _frameTickerShape.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
} }
@ -136,8 +134,8 @@ package org.gestouch.core
{ {
if (!_dirtyGesturesMap[gesture]) if (!_dirtyGesturesMap[gesture])
{ {
_dirtyGestures.push(gesture); _dirtyGesturesMap[gesture] = true;
_dirtyGesturesLength++; _dirtyGesturesCount++;
_frameTickerShape.addEventListener(Event.ENTER_FRAME, enterFrameHandler); _frameTickerShape.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
} }
} }
@ -181,7 +179,7 @@ package org.gestouch.core
gestouch_internal function onTouchBegin(touch:Touch):void gestouch_internal function onTouchBegin(touch:Touch):void
{ {
if (_dirtyGesturesLength > 0) if (_dirtyGesturesCount > 0)
{ {
resetDirtyGestures(); resetDirtyGestures();
} }
@ -263,7 +261,7 @@ package org.gestouch.core
gestouch_internal function onTouchMove(touch:Touch):void gestouch_internal function onTouchMove(touch:Touch):void
{ {
if (_dirtyGesturesLength > 0) if (_dirtyGesturesCount > 0)
{ {
resetDirtyGestures(); resetDirtyGestures();
} }
@ -290,7 +288,7 @@ package org.gestouch.core
gestouch_internal function onTouchEnd(touch:Touch):void gestouch_internal function onTouchEnd(touch:Touch):void
{ {
if (_dirtyGesturesLength > 0) if (_dirtyGesturesCount > 0)
{ {
resetDirtyGestures(); resetDirtyGestures();
} }