hi all,
I have a mouse and stage listener that watches for stage.onResize and Mouse.onMouseDown
they work just fine, however i can’t seem to remove them when i don’t want to use them, they are triggering even though i’ve tried to remove them. Any thoughts on what is wrong with the following code?
private function setEnvironmentListeners(kill){
if(kill){
Stage.removeListener($objStage);
delete $objStage;
$objStage = undefined;
Mouse.removeListener($objMouse);
delete $objMouse;
$objMouse = undefined;
} else {
/*
* Watch for mouse clicks, we will check to see if the user has clicked outside the movieclip,
* if so, then we want the menu to close.
*/
$objMouse = new Object()
$objMouse._name = "listener";
$objMouse._parent = this;
$objMouse.onMouseDown = function(){_parent.dispatchGenEvent({type:"__onMouseDown",_typeof:"MOUSE"});}
Mouse.addListener($objMouse);
/*
* watch for resizing of the stage
*/
$objStage = new Object();
$objStage._name = "listener";
$objStage._parent = this;
$objStage.onResize = function(){_parent.dispatchGenEvent({type:"__onResize",_typeof:"STAGE"});}
Stage.addListener($objStage);
}
// display the listeners to see if they are still there.
trace($objMouse);
trace($objStage);
}