7 Replies Latest reply on Sep 20, 2010 12:12 AM by simplesid

    Centering an Alert box.


      I have a flex web application in which the flex components are embedded inside portal jsps. When the user clicks on a datagrid (clicks on item renderer inside the datagrid), the Alert box has to notify the user. However the alert box centers itself wrt the flex application and it goes out of the user's view. Because the user can view only a portion of the large datagrid at a particular time (scrollbars for the page are present, not for the datagrid).

      I have tried assigning absolute and relative values, but nothing seems to work.

      Any suggestions woudl be greatly appreaciated.

      Thanks in advance.

        • 1. Re: Centering an Alert box.
          Flex harUI Adobe Employee

          Call move(x,y) on the Alert box.

          • 2. Re: Centering an Alert box.




            x="{this.parentApplication.width/2 - this.width/2}"

            y="{this.parentApplication.height/2 - this.height/2}"


            for the Alert, if it not centered w.r.t to the application





            • 3. Re: Centering an Alert box.
              simplesid Level 1

              Thanks guys for giving suggestions, however, the problem is that, i cannnot call move(x,y) because the height of my datagrid and as a result height of my flex application changes everytime. Also, the alert box is centered wrt to the application, but the application thinks that it is displaying the entire grid on the screen. This is happening because the jsp embedding the flex component has a scroll bar and not the flex app itself.The scroll policy for the flex app is set to 'No'.

              The row count for the datagrid is dynamic as well.

              As always... any suggestions are most welcome.

              • 4. Re: Centering an Alert box.
                Flex harUI Adobe Employee

                Can you use ExternalInterface to ask the jsp about the size of the viewport?

                • 5. Re: Centering an Alert box.
                  Biswamit Level 1



                  Your question was not clear................You asked about centering the Alert............But never said that the Flex application is actually embedded in another application


                  Anyways I think as suggested by Flex harUI you do have to use External Call Interface and use some javascript function to find out the size of the viewport so that by that size you can then trying placing that Alert in center


                  Try it .......




                  1 person found this helpful
                  • 6. Re: Centering an Alert box.

                    I've run into a similar situation and here is what I did to resolve it without using the move method...


                    Say you have an application that has a layout container which contains a custom component in it somewhere




                                        |---> CustomComponent (the one that calls the alert box)


                    if your alert box code looks like this:




                    "Your Alert Message Here!","Your Alert Title Here...",0x4,this,null,null);


                    Your alert box will appear centered over the custom component which called it.



                    Add an id to the container you want the alert box centered on:



                           |--->HGroup id="myContainer"

                                        |---> CustomComponent (the one that calls the alert box)


                    Change your alert box code to look like this:




                    "Your Alert Message Here!","Your Alert Title Here...",0x4,this.parentApplication.myContainer,null,null);


                    This will center the alert box over the HGroup layout container that has its id property set to myContainer.


                    The example above sets the parent property of of the Alert class show method:


                    public static function show(text:String = "", title:String = "", flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4):Alert

                    So if I'm understanding your issue correctly... regardless of the size of your viewport you'll maybe want a dynamic method to determine the id porperty of the layout container currently being displayed within the viewport, and then center your alert box over that container via the method above.


                    I hope this helps.

                    • 7. Re: Centering an Alert box.
                      simplesid Level 1

                      Hi Guys,

                      Thanks a lot for your responses (and sorry for my late reply ). But Flex harUI's comment about External Interface solved my problem.

                      Thanks again to everyone.