2 Replies Latest reply on Apr 1, 2014 11:30 PM by rameshreddy.cr

    How to center align Alert.show() in flex


      Hello All,

      I have a tall Flex application that uses Alert.show( ) to display error/warning messages. This created problems when the error messages were centered on the screen, but not visible when the screen was at an extreme scroll position (top or bottom). is there any way that i can display the Alert in the center of the user's viewable page. I've tried the following, but didn't work.

      var errorMsg:Alert = Alert.show("Error message");


      Thanks in advance.

        • 1. Re: How to center align Alert.show() in flex
          Flex harUI Adobe Employee

          It depends on what is doing the scrolling.  centerPopUp() centers on the stage.  If the stage is larger than the viewport and is scrolled you'll need to know about the viewport.  If the viewport is the browser, you might be able to get information about the viewport via ExternalInterface

          • 2. Re: How to center align Alert.show() in flex
            rameshreddy.cr Level 1

            Thanks for your help, yes by using some javascript calls i'm now able center align the Alert.


            Here is the solutions for my problem.

            var viewPoint:Number = ExternalInterface.call("eval", "window.pageYOffset");

            var browserHeight:Number = ExternalInterface.call("eval", "window.innerHeight");

            //the following calculation finds the center y coordinate in user's viewable page.

            var viewableY : Number = ((browserHeight/2)+viewPoint-50);

            var alert : Alert = Alert.show("Error Msg");

            PopUpManager.centerPopUp(alert); alert.move(400,viewableY);

            I hope this helps someone...

            1 person found this helpful