2 Replies Latest reply on Apr 30, 2010 8:40 PM by FTQuest

    multilinelabel or Using the \n key for a label in the Tabbar

    mxvx Level 1

      Hi

       

      Can I have a tabbar label with 2 lines.

       

      For eg. _______________

                |  Adobe   |   Tab   |

                |    Flex    |    2      |

                |________| ______|

       

      Can I have such a label in tab bar.

       

      I actually use a tab navigator from http://groups.google.com/group/flexlib/browse_thread/thread/7e9d36d7d5a352fd/0eec90d460883 666

       

      I am unable to have a multiline tab. I tried overriding the createchildren method but nothign works out ?? Any solutions?

       

      Thanks & Regards

      mxvx

        • 1. Re: multilinelabel or Using the \n key for a label in the Tabbar
          mxvx Level 1

          thanks to harui and google.  The final solution which resolved the problem. At many sites it has been mentioned to override the createChildren() method but from harui's site, i took both the measure and measureText methods. It was working fine .Wud be fine if they would have explained the functionalities too.

           

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

          protected

           

           

           

           

           

          override function createChildren():void {

           

           

          if (!textField)

          {

          textField =

          new UITextField();

          textField.styleName =

          this;

          addChild(DisplayObject(textField));

          }

           

           

          super.createChildren();

           

          textField.multiline =

          true;

          textField.wordWrap =

          true;

           

          this.setStyle("textAlign","left");

          width = 150;

           

          //height = 100;

           

          }

           

           

           

          override protected function measure():void

          {

           

           

          if (!isNaN(explicitWidth))

          {

           

          var w:Number = explicitWidth;

          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;

          }

          }

          }

           

          Thanks & Regards

          mxvx

          • 2. Re: multilinelabel or Using the \n key for a label in the Tabbar
            FTQuest Level 3

            There are shorter solutions; e.g.

             

            <s:Label text="First line{'\n'}Second line" />

            <s:Label text="Third line&#13;Fourth line" />

             

            or you can just put the number of lines you need in the skin file.

             

            HTH,

            FTQuest