Permalink
Browse files

Update playerLoadedCheck to account for player not being on Stage and…

… events added to add proper mouse listeners when added/removed from stage.
  • Loading branch information...
1 parent bc5cdef commit de7e282f3878939471ac69fe7dea5f5a27939ee7 @ryanhefner ryanhefner committed Dec 9, 2011
Showing with 20 additions and 1 deletion.
  1. +20 −1 actionscript/src/com/vimeo/api/VimeoPlayer.as
@@ -95,6 +95,8 @@ package com.vimeo.api
var loader : Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
loader.load(request, loaderContext);
+
+ this.addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler, false, 0, true);
}
public function destroy() : void
@@ -187,7 +189,10 @@ package com.vimeo.api
// remove moogaloop's mouse listeners listener
moogaloop.disableMouseMove();
- stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
+ if (stage)
+ {
+ stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
+ }
dispatchEvent(new Event(Event.COMPLETE));
}
@@ -269,6 +274,20 @@ package com.vimeo.api
this.redrawMask();
}
+ // Event Handlers ____________________________________________________
+
+ private function addedToStageHandler(event:Event) : void
+ {
+ stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
+ this.addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageHandler, false, 0, true);
+ }
+
+ private function removedFromStageHandler(event:Event) : void
+ {
+ stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
+ this.removeEventListener(Event.REMOVED_FROM_STAGE, removedFromStageHandler, false, 0, true);
+ }
+
/**
* API v2 Event Handlers
*/

0 comments on commit de7e282

Please sign in to comment.