4 Replies Latest reply on Jul 29, 2013 7:21 AM by Loic.Aigon

    Alert & long alertLabel Issue

    Loic.Aigon Adobe Community Professional

      Hi,

       

      I can't get to correctly display a text within an Alert component. I tried the TitleWindow component too but it still doesn't solve my issue. If my alert string is long, the fitting isn't ok.

       

       

      In this example, I set a static big height and it's "ok".

       

      Image IPB

       

      But if I let the component to draw itself, this is what I get :

       

      Image IPB

       

      I tried to override measure and updateDisplayList based on text dimensions but without luck.

       

      Any advice ?

       

      TIA.

       

      Loic

        • 1. Re: Alert & long alertLabel Issue
          Craberoid Level 1

          Using non-absolut positions and maxDisplayedLines property will be help you.

           

          MyAlert.mxml

          <?xml version="1.0" encoding="utf-8"?>

          <s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"

                                           xmlns:s="library://ns.adobe.com/flex/spark"

                                           xmlns:mx="library://ns.adobe.com/flex/mx" creationPolicy="all" maxWidth="400">

                    <fx:Declarations>

                              <!-- Place non-visual elements (e.g., services, value objects) here -->

                    </fx:Declarations>

                    <fx:Script>

                              <![CDATA[

                                        import mx.core.FlexGlobals;

                                        import mx.managers.PopUpManager;

           

                                        public static function show(caption:String):void

                                        {

                                                  var alert:MyAlert = new MyAlert();

                                                  PopUpManager.addPopUp(alert, DisplayObject(FlexGlobals.topLevelApplication));

                                                  alert.message.text = caption;

                                        }

           

                              ]]>

                    </fx:Script>

                    <s:Label id="message" maxDisplayedLines="-1" left="5" right="5" bottom="5" top="5" />

          </s:TitleWindow>

           

          test_screen.png

          • 2. Re: Alert & long alertLabel Issue
            Loic.Aigon Adobe Community Professional

            Hi Craberoid,

             

            Thanks for the hint. MaxDisplayedLines seems only accessible with the Flex 4 sdk, right ? I have to get it working with the Flex 3 sdk.

             

            Thanks a lot anyway

             

            Loic

            • 3. Re: Alert & long alertLabel Issue
              fB3 Level 2

              For Flex 3 try this....

               

              <?xml version="1.0" encoding="utf-8"?>

              <mx:Application 

                xmlns:mx="http://www.adobe.com/2006/mxml

                creationComplete="onAppInit()"

                layout="horizontal"> 

               

                <mx:Script> 

                 <![CDATA[ 

                      import mx.core.IUITextField;

                      import mx.controls.Alert;

                      import mx.core.mx_internal;

                      use namespace mx_internal;

               

                      public function onAppInit():void

                      {

                          showAlert();

                      }

                      private function showAlert():void

                      {

                          var myAlert:Alert = Alert.show("Mot de passe ou identifiant errone !", "Alert");

                          myAlert.height = 160;

                          myAlert.width = 340;

                          callLater(function():void

                          {

                              var textField:IUITextField =  IUITextField(myAlert.mx_internal::alertForm.mx_internal::textField);

               

                              var textFormat:TextFormat = new TextFormat();

                              textFormat.align = "center";

               

                              textField.width = myAlert.width;

                              textField.x = -10;

                              textField.setTextFormat(textFormat);

                          });

                      }

               

               

                 ]]>

                </mx:Script>

              <mx:Style>

                  Application {

                       backgroundColor:#FFFFFF;

                       backgroundGradientColors: #FFFFFF,#FCFDFF ;

                  }

                  .myHeaderStyles {

                      color:#FFFFFF;

                      fontWeight: bold;

                  }

               

                  Alert{

                      color : #124332;

                      background-color: #ffffff;

                      header-colors : #d4d4d4, #d4d4d4;

                      header-height:19;

                      drop-shadow-enabled: true;

                      drop-shadow-color :#243322;

                      corner-radius :6;

                      border-style :solid;

                      border-thickness: 1;

                      border-color : #243322;

                      footer-colors : #243322, #ffffff;

                      title-style-name : "title";

                  }

                  </mx:Style>

              </mx:Application>

               

               

              Will create this...

               

              alert.fw.png

              HTH

              • 4. Re: Alert & long alertLabel Issue
                Loic.Aigon Adobe Community Professional

                Hi HTH

                 

                Thanks for all your effort. Your solution was very helpful

                 

                Loic