开发者

Auto-resizing Spark TextArea using Flex Hero

开发者 https://www.devze.com 2023-02-06 05:31 出处:网络
I\'m trying to auto-resize a Spark TextArea using Flex Hero but having no luck. Can anyone point me i开发者_运维百科n the direction of a working example please?

I'm trying to auto-resize a Spark TextArea using Flex Hero but having no luck. Can anyone point me i开发者_运维百科n the direction of a working example please?

EDIT: To clarify, I want to auto-resize the TextArea when typing, so there's never a scroll bar.


After some playing around I found a way to do it:

<?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>


I just set the width/height to be a percentage of the container:

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

Unless you are asking something else?


I just tested it with flex hero, and as Bruno Trincão posted here, s:RichEditableText works with textArea.heightInLines = NaN;

0

精彩评论

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