使用Flex Hero自动调整Spark TextArea的大小

时间:2011-01-24 17:27:48

标签: flex

我正在尝试使用Flex Hero自动调整Spark TextArea的大小,但没有运气。有人能指出我的工作方向吗?

编辑:为了澄清,我想在输入时自动调整TextArea的大小,所以从来没有滚动条。

3 个答案:

答案 0 :(得分:2)

经过一番游戏,我找到了办法:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx">
    <s:layout>
        <s:VerticalLayout paddingLeft="10" paddingRight="10" paddingTop="8" paddingBottom="8"/>
    </s:layout>
    <fx:Script>
        <![CDATA[
            import mx.core.mx_internal;

            protected function changeTextArea():void
            {
                textArea.heightInLines = NaN;
            }

            protected function lineCount():void
            {
                label.text = textArea.textFlow.flowComposer.numLines.toString();
            }
        ]]>
    </fx:Script>
    <s:TextArea id="textArea"
                heightInLines="1"
                horizontalCenter="0" verticalCenter="0" verticalScrollPolicy="off" horizontalScrollPolicy="off"
                change="changeTextArea()" focusOut="lineCount()"/>
    <s:Label id="label"/>
    <s:Button/>
</s:WindowedApplication>

答案 1 :(得分:0)

我只是将宽度/高度设置为容器的百分比:

<s:TextArea width="100%" height="100%" />

除非你问别的什么?

答案 2 :(得分:0)

我刚用flex hero测试了它,当BrunoTrincão发布here时,s:RichEditableTexttextArea.heightInLines = NaN;一起使用