4 Replies Latest reply on Oct 20, 2009 12:38 PM by Jerry62712

    How Do I split the text on a label

    Jerry62712 Level 1

      I have two labels and would like to consolidate them into one.  That would require a label to have two lines of text on it.  I'm worried about trying to restrict the size of the label because it will have to grow when the font size is increased.  Is it possible to use a "\n" type of construct?

        • 1. Re: How Do I split the text on a label
          Subeesh Arakkan Level 4

          Yes

           

          <mx:Text htmlText="two&#13;lines"/>

          • 2. Re: How Do I split the text on a label
            Jerry62712 Level 1

            How embarrassing for me.  I don't have two labels, I have two linkButtons with a property "label" in them.  Unfortunately, linkButtons don't have an htmlText property.  Sorry for my confusion.

            • 3. Re: How Do I split the text on a label
              Subeesh Arakkan Level 4

              Check Alex's post. He extends a RadioButton control in the example. You can do the same thing with LinkButton.

              http://blogs.adobe.com/aharui/2007/04/multiline_buttons.html

              • 4. Re: How Do I split the text on a label
                Jerry62712 Level 1

                Thanks for the link.  I'm afraid I'm just too slow to get it.  Here is the code example he had that I downloaded:

                package
                {
                import flash.text.TextLineMetrics;
                import mx.controls.RadioButton;
                import mx.core.IFlexDisplayObject;
                import mx.core.mx_internal;
                use namespace mx_internal;
                public class MultilineRadioButton extends RadioButton
                {
                    public function MultilineRadioButton()
                    {
                        super();
                    }
                    override protected function createChildren():void
                    {
                        if (!textField)
                        {
                            textField = new NoTruncationUITextField();
                            textField.styleName = this;
                            addChild(textField);
                        }
                        super.createChildren();
                        textField.multiline = true;
                        textField.wordWrap = true;
                    }

                    override protected function measure():void
                    {
                        if (!isNaN(explicitWidth))
                        {
                            var tempIcon:IFlexDisplayObject = getCurrentIcon();
                            var w:Number = explicitWidth;
                            if (tempIcon)
                                w -= tempIcon.width + getStyle("horizontalGap") + getStyle("paddingLeft") + getStyle("paddingRight");
                            textField.width = w;
                        }
                        super.measure();
                    }
                    override public function measureText(s:String):TextLineMetrics
                    {
                        textField.text = s;
                        var lineMetrics:TextLineMetrics = textField.getLineMetrics(0);
                        lineMetrics.width = textField.textWidth + 4;
                        lineMetrics.height = textField.textHeight + 4;
                        return lineMetrics;
                    }
                }
                }

                I deleted the line spacing to save space here.  I can't see how to apply that to this:

                    <mx:LinkButton id="headerIDHSLinkText"
                        label="Illinois"
                        fontFamily="Arial"
                        fontSize="13"
                        fontWeight="bold"
                        left="80" top="0"
                        click="linkIDHS('http://www.dhs.state.il.us')"
                        toolTip="Illinois Department of Human Services Web page Link"
                        tabIndex="1"/>

                One of the blog entries mentioned changing a "#13" and I can't even find that in his source.