8 Replies Latest reply on Aug 24, 2010 9:04 PM by Flex harUI

    mx Alert.Show in a different window


      Hi everybody, I'm developing a simple application in Flex  (using Air, it's a desktop application).  And I've got a problem showing some messages to the user.


      You'll see,  I have my main window (mx:WindowedApplication) which has a button that calls another window (mx:Window). In this second window I want to show a message.


      When I write this code in my second window:




      The alert pop-up  appears in the first one, that's to sat, in the main application. And that's not supposed to happen.

      I've tried writing this.


      Alert.Show("myMessage","myTittle",4, this as Sprite);


      And it works perfectly!... but throws an Error when executing the app.


      Remember, this code is in the second window. So, I've got no idea why this keeps appearing in the first one.



             Thank you and I apologize for my English it's not my first language!  Bye!

        • 1. Re: mx Alert.Show in a different window

          Instead of using Alert, try using PopupManager to display a component that extends IFlexDisplayObject. It takes 30 secs to write one that mimmicks Alert, and you don't get these problems.

          1 person found this helpful
          • 2. Re: mx Alert.Show in a different window
            feresr Level 1

            Well thanks, I'm gonna try to do that. And I'll let you know how it went. 


            But if someone knows how to make 'Alert' works. Please let me know.



            • 3. Re: mx Alert.Show in a different window
              feresr Level 1

              By the way, I haven't heard about 'PopUpMaganer', and I don't know how to use it.

              Can someone Explain to me what its atributes are?.




              I would prefer not to create the window. with the buttons. That's why I'm interested on 'Alert'.


              • 4. Re: mx Alert.Show in a different window
                Vackar Level 2

                window:IflexDisplayObject => This is the popup you want to show

                parent:DisplayObject => This is the parent window of the popup

                modal:Boolean=> if this is true, you cannot interact with the parent while it's being shown

                • 5. Re: mx Alert.Show in a different window
                  Vackar Level 2

                  And here's a sample popup:


                  <?xml version="1.0" encoding="utf-8"?>
                       layout="vertical" width="100%" height="100%" 
                            <mx:VBox styleName="paddedFive" horizontalAlign="center">
                                 <mx:HBox width="100%"  verticalAlign="middle">
                                      <mx:Image source="{imgToUse}" />
                                      <mx:Label text="{messageText}" />
                                 <mx:Button label="Close" click="{PopUpManager.removePopUp(this)}" />
                           import mx.rpc.events.ResultEvent;
                           import mx.controls.Alert;
                           import mx.managers.PopUpManager;
                          public static var imgOk:Class;
                          public static var imgError:Class;
                          public static var imgWarning:Class;
                          private var imgToUse:Class = null;
                          private var messageText:String = null;
                          private var titleMessage:String = "Message";
                         public function init(messageText:String, imgToUse:Class, titleMessage:String = null)
                                   this.messageText = messageText;
                                   this.imgToUse = imgToUse;
                                  this.titleMessage = titleMessage;
                            public function get MessageText()     {
                                 return messageText;
                            public function set MessageText(messageText:String)     {
                                 this.messageText = messageText;
                            public function get ImgToUse()     {
                                 return imgToUse;
                            public function set ImgToUse(imgToUse:Class)     {
                                 this.imgToUse = imgToUse;
                  • 6. Re: mx Alert.Show in a different window
                    feresr Level 1

                    Thank you Vackar,  it's a nice option...  but Adding a new .mxml  just to create a popUp doesn't seem a good idea to me.  I've got to create 6 popUps in my app. And I there must be a easier way to do it.


                    If anyone know how to fix  the Alert.Show method I'll be more than glad.


                    I've asked this very same question in another Forum. And they referred me to this webSite




                    Unfortunelly, I don't get it. I can't get my app working with that code, Although It doesn't throw an error, the pupUp appears In the wrong window.




                    • 7. Re: mx Alert.Show in a different window
                      feresr Level 1


                      Oh! And one more thing. I've tried to write the code this way:


                               Alert.show("Uno o mas Campos tienen errores. Por favor controle los datos ingresados","Libro no creado",4, this as Sprite);



                      And it works!   Perfectly!.  But whit a little detail,  It throws a error:


                      Wanna see it ?:




                      TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::WindowedSystemManager@79760b1 to mx.managers.SystemManager.

                           at mx.accessibility::AlertAccImpl/eventHandler()[E:\dev\4.x\frameworks\projects\framework\sr c\mx\accessibility\AlertAccImpl.as:187]

                           at flash.events::EventDispatcher/dispatchEventFunction()

                           at flash.events::EventDispatcher/dispatchEvent()

                           at mx.core::UIComponent/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\core \UIComponent.as:12528]

                           at mx.core::UIComponent/set initialized()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1627]

                           at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framewo rk\src\mx\managers\LayoutManager.as:759]

                           at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects \framework\src\mx\managers\LayoutManager.as:1072]

                      • 8. Re: mx Alert.Show in a different window
                        Flex harUI Adobe Employee

                        There should already be a bug on that.