Search code examples
actionscript-3user-interfaceflex3stack-overflow

Flex Popup Window: Stack Overflow?


I'm somehow creating a stack overflow in Flex 3...I'm trying to get data out of a modal dialogue window as such:

Main application:

var myPopup:MyPopup;

function buttonClick( event:MouseEvent ):void
{
myPopup = MyPopup( PopUpManager.createPopUp( this, MyPopUp, true ) );
myPopup.addEventListener( CloseEvent.CLOSE, handler, false, 0, true );
}

function handler():void
{
//get data
}

MyPopup:

function buttonHandler( MouseEvent:event ):void
{
PopUpManager.remove( this );
this.dispatchEvent( new CloseEvent( CloseEvent.CLOSE ) );
}

If this is improper, what is the correct way to handle closing of the popup in a manner that allows me to use and retrieve data on the object?


Solution

  • Perhaps you could try adding an event parameter to your handler. I'm not so sure that ActionScript can always tolerate that not being provided. Example:

    function handler(event:CloseEvent):void {
        // Handle away
    }
    

    I also second the practice of calling the handler before dismissing the popup as mentioned by Justin.