4 Replies Latest reply on Oct 24, 2011 11:51 AM by Zolotoj

    Alert Box question

    Zolotoj Level 3

      Is it possible to add a button to an Alert box's title bar or at least make it respond to a click?



        • 1. Re: Alert Box question
          highlightscript Level 1

          Yes you can. Alert comes from Panel (mx.controls.Panel). So check the properties and methods for Panel

          • 2. Re: Alert Box question
            Zolotoj Level 3

            Is there a chance you could show some code, please?

            • 3. Re: Alert Box question
              Zolotoj Level 3

              Here is some fragments of code I got so far:



                  import flash.events.MouseEvent;

                  import flash.utils.describeType;


                  import mx.containers.VBox;

                  import mx.controls.Alert;

                  import mx.controls.Button;

                  import mx.core.LayoutContainer;

                  import mx.utils.*;


                  import spark.skins.spark.TitleWindowCloseButtonSkin;


                  public class AlertEx extends Alert


                      private var _titleBtn:Button=new Button();

                      private var _titleSparkBtn:TitleWindowCloseButtonSkin=new TitleWindowCloseButtonSkin();

                      public function AlertEx()



                          this.addEventListener("click", onClick);

                          this.text = "Test";

                          this.title = "Error";           


                      override protected function createChildren():void



                          _titleSparkBtn.addEventListener("click", onClick);



                      private function onClick(event:MouseEvent):void




                      override protected function updateDisplayList (unscaledWidth:Number, unscaledHeight:Number):void{


                          super.updateDisplayList(unscaledWidth, unscaledHeight);

                          _titleBtn.move(100, 2);






              The result basically looks like this:


              While I do have a close button here but I can't find a way of positioning it to the right corner. Any idea?



              • 4. Re: Alert Box question
                Zolotoj Level 3

                I got it, nevermind.