4 Replies Latest reply on Jul 31, 2011 1:45 AM by Flex Rock

    Alert.show Does Not Work if Called from ActionScript

    mlavie Level 1

      I am using Flex v3.4 (because I am writing for the Creative Studio CS5 SDK) on WIndows 7.

       

      I am writing code in an ActionScript class (in a lib project) which is designed to display an Alert box via Alert.show(). The method is called from a component based on mx:Canvas, and the copmonent is in turned used in an mx:Application.

       

      No matter what I do, I can not get the Alert box to appear. I have tried specifying the Component and the Component's .parentApplication as the Sprite for the Alert.show() method, but nothing seems to work.

       

      I'd really appreciate some help here.

       

      mlavie

        • 1. Re: Alert.show Does Not Work if Called from ActionScript
          Flex Rock Level 1

          Hi,

              Can you post your code here. So that we can have brief look into what you are trying to do.

           

          Thanks,

          Jayagopal.

          • 2. Re: Alert.show Does Not Work if Called from ActionScript
            mlavie Level 1

            Hi Jayagopal,

             

            I defined a Component which inherits from mx:Canvas. I set its labelFunction to "GetTreeNodeLabel".

             

            The function "GetTreeNodeLabel" contains, among other things, the following code:

             

            <code>

                try
                {
                 elementType = p_item.localName().toString();
                }
                catch(error:Error)
                {
                 var advError:AdvError = new AdvError(error, "Able was I ere I saw Elba.");
                 advError.DisplayAlert(this.parentApplication);
                 throw advError;    

                }
            </code>

             

            In the event of an error, I want a modal, synchronous pop-up Alert.show() box to appear with my custom message. The class AdvError which I wrote inherits from Error, and was written primarily to provide the method "DisplayAlert()" which will produce a nicely formatted and user-friendly error screen when an error occurs.

             

            The code for that class is as follows:

             

            <code>

            // AdvError class: for extending functionality of the base Error class
            public class AdvError extends Error
            {
              // Application-specific message to be displayed for the error
              private var m_applicativeMessage:String;
             
              // CTOR
              public function AdvError(p_error:Error, p_applicativeMessage:String)
              {
               super(p_error.message, p_error.errorID);
              
               m_applicativeMessage = p_applicativeMessage;
              }
             
              // Display user/programmer freindly information for the error
              public function DisplayAlert(p_callingContext:Sprite) :void
              {
               var alertMessage:String;
              
               alertMessage = "Severe Warning: \r\n" + m_applicativeMessage;

               Alert.show(alertMessage, "Alert Message", mx.controls.Alert.OK, p_callingContext);

              }
            }

            Please help!

             

            Regards,

            mlavie

             

            </code>

            • 3. Re: Alert.show Does Not Work if Called from ActionScript
              dmutantz

              Jayagopal

               

              If you ask the guy to post his / her code you could at least look at it and give them an answer

              • 4. Re: Alert.show Does Not Work if Called from ActionScript
                Flex Rock Level 1

                Hi,

                 

                Is it throwing an error or silently not responding anything.

                 

                Regards,

                Jayagopal.