0
votes

I'm beginner in Flex 4. I'm trying to pop up a Flex WindowTitle custom component, and after the user choose some values, the parent window must be refreshed.

I'm showing the modal window, the user can't interact with other components, but the problem I detect is the execution of the program flows, even I choosing to show the Input window as modal, the next methods to refresh the page is called before the user close the modal page. I don't know if flex or ActionScript works different from Java, where I used to code.

Please, see the comments on the code example:

<fx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.core.FlexGlobals;
        import mx.managers.PopUpManager;

        public function add_clickHandler(event:MouseEvent):void
        {
            var frm: FrmNovaOpcao = new FrmNovaOpcao();//titleWindow

            //add modal window
            PopUpManager.addPopUp(frm, this, true);
            //center modal window
            PopUpManager.centerPopUp(frm);

            refreshAll(); //this method is being called before the user close the modal window =[


        }
    ]]>
</fx:Script>
1

1 Answers

0
votes

I solved adding event handlers and callback functions to the modal windows. I research and understood that flex is event driven, and prioritize the UI refresh, and don't work with threads.

Not bad to a UI driven technology.

<fx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.core.FlexGlobals;
        import mx.managers.PopUpManager;

        protected function add_clickHandler(event:MouseEvent):void
        {
            var frm: FrmNovaOpcao = new FrmNovaOpcao();

            //add modal window
            PopUpManager.addPopUp(frm, this, true);
            //center modal window
            PopUpManager.centerPopUp(frm);

            frm.btnAdd.addEventListener(MouseEvent.CLICK, refreshOptions);          

        }

        protected function refreshOptions(mousevent:MouseEvent):void{
             refreshAll(); 
        }
    ]]>