Search code examples
actionscript-3flex4

How to call "this" from an anonymous method?(flex, as)


This is my code:

public function setPaneContent(names : Array, parent : AbstractPane) : void  {
//....

 okButton.addEventListener(MouseEvent.CLICK, function okMouseClickHandler(e : Event) : void {
                parent.addNewPane(valuesPane, parent);


                    PopUpManager.removePopUp(/*need to put "this"*/);

                });
 //.....
}

When i call PopUpManager.removePopUp(/*need to put "this"*/);, i need to make a reference at the object that contains this method(this).

So my question is: "Is it possible to make a reference at 'this' keyword within an anonymous method?"


Solution

  • store this to some variable: _this = this in the constructor, use _this. (it works in javascript)