Add protected from a mistyped event listening

This commit is contained in:
Pavel fljot 2012-08-07 17:46:12 +03:00
parent a3b618e90a
commit 2678e12de8
8 changed files with 62 additions and 2 deletions

View file

@ -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";
}
//--------------------------------------------------------------------------

View file

@ -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();

View file

@ -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)

View file

@ -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)

View file

@ -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();

View file

@ -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();

View file

@ -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)

View file

@ -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)