Permalink
Browse files

Destructor added, removes listeners from Stage.

Signed-off-by: Vaclav Vancura <vaclav@vancura.org>
  • Loading branch information...
1 parent 98d04fa commit a13892f9bf8718b323d33394bf987373d0068660 @vancura vancura committed Jul 25, 2011
Showing with 13 additions and 0 deletions.
  1. +13 −0 com/iainlobb/gamepad/Gamepad.as
@@ -80,12 +80,15 @@ package com.iainlobb.gamepad
* @param autoStep Pass in false if you intend to call step() manually.
*/
+ private var stage:Stage;
+
public function Gamepad(stage:Stage, isCircle:Boolean, ease:Number = 0.2, autoStep:Boolean = true)
{
trace('Remember to hit "Control > Disable Keyboard Shorcuts" in the Flash IDE & stand-alone Flash player!');
this.isCircle = isCircle;
this.ease = ease;
+ this.stage = stage;
_up = new GamepadInput();
_down = new GamepadInput();
@@ -116,6 +119,16 @@ package com.iainlobb.gamepad
}
}
+ /*
+ * Destructor.
+ */
+
+ public function destroy():void {
+ stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
+ stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyUp);
+ stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
+ }
+
// DIRECTION PRESETS
/*

0 comments on commit a13892f

Please sign in to comment.