mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2024-11-27 01:35:40 -05:00
Add protected from a mistyped event listening
This commit is contained in:
parent
a3b618e90a
commit
2678e12de8
8 changed files with 62 additions and 2 deletions
|
@ -200,6 +200,17 @@ package org.gestouch.gestures
|
|||
//
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
override public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
|
||||
{
|
||||
if (!eventTypeIsValid(type))
|
||||
{
|
||||
throw new ArgumentError("Event type does not match any of allowed values.");
|
||||
}
|
||||
|
||||
super.addEventListener(type, listener, useCapture, priority, useWeakReference);
|
||||
}
|
||||
|
||||
|
||||
[Abstract]
|
||||
/**
|
||||
* Reflects gesture class (for better perfomance).
|
||||
|
@ -546,6 +557,13 @@ package org.gestouch.gestures
|
|||
}
|
||||
|
||||
|
||||
protected function eventTypeIsValid(type:String):Boolean
|
||||
{
|
||||
// propertyChange just in case for bindings?
|
||||
return type == GestureStateEvent.STATE_CHANGE || type == "propertyChange";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
|
|
@ -71,6 +71,12 @@ package org.gestouch.gestures
|
|||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
override protected function eventTypeIsValid(type:String):Boolean
|
||||
{
|
||||
return type == LongPressGestureEvent.GESTURE_LONG_PRESS || super.eventTypeIsValid(type);
|
||||
}
|
||||
|
||||
|
||||
override protected function preinit():void
|
||||
{
|
||||
super.preinit();
|
||||
|
|
|
@ -112,6 +112,12 @@ package org.gestouch.gestures
|
|||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
override protected function eventTypeIsValid(type:String):Boolean
|
||||
{
|
||||
return type == PanGestureEvent.GESTURE_PAN || super.eventTypeIsValid(type);
|
||||
}
|
||||
|
||||
|
||||
override protected function onTouchBegin(touch:Touch):void
|
||||
{
|
||||
if (touchesCount > maxNumTouchesRequired)
|
||||
|
|
|
@ -56,6 +56,12 @@ package org.gestouch.gestures
|
|||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
override protected function eventTypeIsValid(type:String):Boolean
|
||||
{
|
||||
return type == RotateGestureEvent.GESTURE_ROTATE || super.eventTypeIsValid(type);
|
||||
}
|
||||
|
||||
|
||||
override protected function onTouchBegin(touch:Touch):void
|
||||
{
|
||||
if (touchesCount > 2)
|
||||
|
|
|
@ -120,6 +120,12 @@ package org.gestouch.gestures
|
|||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
override protected function eventTypeIsValid(type:String):Boolean
|
||||
{
|
||||
return type == SwipeGestureEvent.GESTURE_SWIPE || super.eventTypeIsValid(type);
|
||||
}
|
||||
|
||||
|
||||
override protected function preinit():void
|
||||
{
|
||||
super.preinit();
|
||||
|
|
|
@ -79,6 +79,12 @@ package org.gestouch.gestures
|
|||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
override protected function eventTypeIsValid(type:String):Boolean
|
||||
{
|
||||
return type == TapGestureEvent.GESTURE_TAP || super.eventTypeIsValid(type);
|
||||
}
|
||||
|
||||
|
||||
override protected function preinit():void
|
||||
{
|
||||
super.preinit();
|
||||
|
|
|
@ -61,6 +61,12 @@ package org.gestouch.gestures
|
|||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
override protected function eventTypeIsValid(type:String):Boolean
|
||||
{
|
||||
return type == TransformGestureEvent.GESTURE_TRANSFORM || super.eventTypeIsValid(type);
|
||||
}
|
||||
|
||||
|
||||
override protected function onTouchBegin(touch:Touch):void
|
||||
{
|
||||
if (touchesCount > 2)
|
||||
|
|
|
@ -55,6 +55,12 @@ package org.gestouch.gestures
|
|||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
override protected function eventTypeIsValid(type:String):Boolean
|
||||
{
|
||||
return type == ZoomGestureEvent.GESTURE_ZOOM || super.eventTypeIsValid(type);
|
||||
}
|
||||
|
||||
|
||||
override protected function onTouchBegin(touch:Touch):void
|
||||
{
|
||||
if (touchesCount > 2)
|
||||
|
|
Loading…
Reference in a new issue