views:

43

answers:

2

Hi:

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?" Thanks advance!

Blockquote

+3  A: 

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

igor
+2  A: 

You don't have to, you can call another function

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

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

            // call the remove function where you can reference "this"
            remove();
         });
         //.....
}

private function remove():void
{ 
    PopUpManager.removePopUp(this);
}
PatrickS