Skip navigation
Currently Being Moderated

Alert & long alertLabel Issue

Jul 26, 2013 4:01 AM

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

 
Replies
  • Currently Being Moderated
    Jul 27, 2013 7:01 AM   in reply to Loic_aigon

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 28, 2013 6:31 PM   in reply to Loic_aigon

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points