How to remove an event listener from a different class?
I have 2 class of code, A and B
In class B there is a public static function addEL like this
public static function addEL (targetObject:Object):void
{
//add click event listener on btn_B
targetObject.btn_B.addEventListener(MouseEvent.CLICK, btnB_doSomething);
function btnB_doSomething(event:MouseEvent):void
{
//do something
}
}
This addEL function is called in class A right after I add a movieClip instance of Class B onto the stage.
What I want to do is to use removeEventListener() to remove that handler from class A by pressing a key
It works fine if I use removeEventListener() in that addEL function by creating a click event listener in addEL
but in this way, I couldn't find a way to trigger it by pressing a key since that function only runs one time.
I'm not very familiar with the effective range of the function removeEventlistener(), what is the range limit of it or how does it work?
How exactly should I do if I want to remove the handler in a different Class, is it even possible to achieve?
I tried to find answer on all different places, but couldn't find a similar situation.
