开发者

flex 3 resize the label and text when i resize the window

i am creating flex 3 component when i re开发者_Go百科 size the window i need to re size the labels and text.how to do this?

Thanks.


Did you try a width and height in percent?

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

As far as the text is concerned, check out this trick used 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;
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜