mirror of
https://github.com/scratchfoundation/Gestouch.git
synced 2024-11-23 07:47:59 -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
|
@ -198,7 +198,18 @@ package org.gestouch.gestures
|
|||
//
|
||||
// Public methods
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
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]
|
||||
/**
|
||||
|
@ -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";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
|
|
@ -53,7 +53,7 @@ package org.gestouch.gestures
|
|||
return TapGesture;
|
||||
}
|
||||
|
||||
|
||||
|
||||
override public function reset():void
|
||||
{
|
||||
super.reset();
|
||||
|
@ -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