代码之家  ›  专栏  ›  技术社区  ›  aravinda

flex 3在调整窗口大小时调整标签和文本的大小

  •  0
  • aravinda  · 技术社区  · 16 年前

    我正在创建flex 3组件,当我重新调整窗口大小时,我需要重新调整标签和文本的大小。如何做到这一点?

    1 回复  |  直到 16 年前
        1
  •  0
  •   MonoThreaded    16 年前

    <mx:Label text="This is my text" width="100%" height="100%"/>
    

    就文本而言,请查看使用的这个技巧 here

        /**
         * Cheesy loop to find what should be the font size to fit the text in the inner rectangle
         * This is invoked by creationComplete (or whenever you want to resize the font)
         */
        private function resize():void {
            var tf:TextField = lSpeech.mx_internal::getTextField();
            var textFormat:flash.text.TextFormat = tf.getTextFormat();
    
            while( tf.height > height * 0.707 && textFormat.size > 1 && labelFontSize > 1) {
                textFormat.size = int( textFormat.size) - 1;
                labelFontSize--;
                tf.setTextFormat( textFormat);
                lSpeech.validateNow();
            }
            // repsition the label (vertical center)
            lSpeech.y = (height - tf.height) / 2 - 10;
            lSpeech.height = tf.height;
        }
    
    推荐文章