5 Replies Latest reply on Jun 15, 2009 4:00 AM by Bram Van Oost

    PopUpManager

    Bram Van Oost

      Hi Flexers,

       

      When I press a certain button, I do two things:

      - disable the button

      - open a popup with a form

       

      When I hit cancel on that form, the button should be enabled again.

       

      Both the functions and the popup window information are in seperate files (components/files).

      When I add a function to the cancel button (in the seperate file), it doesn't recognise it.

       

      Anyone that can help me with this?

      Thanks a bunch!

        • 1. Re: PopUpManager
          Benji2008 Level 1

          what you need is a callback function - in the callbackfunction you can then enable the button again

          • 2. Re: PopUpManager
            Bram Van Oost Level 1

            Hi Benji,

             

            Thanks for your reply!

            Would you happen to have direction/an example?

             

            Second thought:

            I noticed in some examples that the 'main window' (so below the popup) gets blurred out and has no functionality while the popup is present.

            This would fix everything and erase the need to disable the button. How do I do this?

             

            Yes, kinda new at Flex. :-)

            • 3. Re: PopUpManager
              Benji2008 Level 1

              actually I cant find a good example to demonstrate it :s

               

              but here is how it should work:

               

              Bare with me as I havent tested it at all..

               

              //as Last parameter add a function, like so:

              NewProfileDialog.prompt(value1,value2,onDialogComplete);


              //the callbackfunction

               

              public function onDialogComplete():void

              {

              //enable your button again here

              }

               

              --

              in your popup class

              * define a property that is a function

              * accept a parameter that is the function

              * in the that constructer set the property you made above equal to the new incoming function parameter

               

              then in the function your done - so I guess when you clicked cancel - check if the function != null - then do the callback

              - call the function you made

              ---

              so ..

               

              private var _callbackfunction:Function = null;

               

              popupmanger(value1:String,value2:String,onDialogComplete:Function)

              {

              callbackfunction = onDialogComplete;

              }

               

              //in the function that you want to do the callback

              public function close():void

              {

              if (callbackfunction != null)

              callbackfunction();

              }

               

              ---

               

              err might look a bit unclear but if it really still is, post the lines of code that refer to your popupmanger

              and post the popupmanger and Ill try to fix it for ya

              • 4. Re: PopUpManager
                Gregory Lafrance Level 6

                Define a close handler for the popup, and refer to the other component through the main app:

                 

                mx.core.Application.application.myOtherComp.myButton.enabled = true;

                 

                If this post answers your question or helps, please mark it as such.

                • 5. Re: PopUpManager
                  Bram Van Oost Level 1

                  Thanks a lot for your enthousiasm, Benji and Greg.

                  Looking at the code I think it'll be quite transparant and I should make it work, but due to deadlines it'll take a while before I can apply it.

                   

                  I'll mark the issue as solved, hopefully, it actually will be! :-)

                   

                  Thanks again, really appreciate the support.