Flex: Sending parameters to Alert closeHandler

后端 未结 4 2121
天涯浪人
天涯浪人 2020-12-19 03:37

Is it possible to send parameters to a closeHandler Alert function? The fisrt parameter the function gets is the CloseEvent, but how to send another one?

<         


        
4条回答
  •  北海茫月
    2020-12-19 04:03

    My typical method of handling this use case is to add the data to the Alert form. For example

    var o:Object = new Object();
    o["stuff"] = "quick brown fox";
    
    var alert:Alert = Alert.show("Message", "Title", mx.controls.Alert.YES | mx.controls.Alert.NO, null, OnAlertResult);
    alert.data = o;
    

    And then in the close handler for the Alert

    private function OnAlertResult(event:CloseEvent):void {
        trace(event.target.data);
    }
    

提交回复
热议问题