处于其他状态时,TextArea文本未设置

时间:2012-09-01 07:19:45

标签: flex flex4 stage

TextArea.text值未设置或保持设置。当我进行转换并使用Rotate3D并且有两个转换时会发生这种情况。只需一次转换即可。有两个转换(返回转换),它没有。所以在下面的例子中,我有一个从“note”到“list”的转换。如果我添加从“列表”到“注释”的转换,则会发生该行为。但是,如果我将textArea(注释)放在两个状态,那么它正常工作(即incluedIn =“note,list”工作)!

<s:Group id="noteGroup" includeIn="note">

    <s:TextArea id="normalTextArea" />

</s:Group>


<s:transitions>
    <s:Transition fromState="note" toState="list"
                  autoReverse="false">
        <s:Sequence target="{this}"
                    duration="{duration}" >
            <s:Rotate3D angleYFrom="0" angleYTo="90" 
                        autoCenterTransform="true" 
                        applyChangesPostLayout="true"
                        />
            <s:SetAction target="{noteGroup}" property="visible" />
            <s:RemoveAction target="{noteGroup}" />
            <s:AddAction target="{listGroup}"/>
            <s:Rotate3D angleYFrom="-90" angleYTo="0" 
                        autoCenterTransform="true" 
                        applyChangesPostLayout="true"/>
        </s:Sequence>
    </s:Transition>

    <s:Transition fromState="list" toState="note"
                  autoReverse="false"
                  >
        <s:Sequence target="{this}" duration="{duration}" >

            <s:Rotate3D angleYFrom="0" angleYTo="-90" 
                        effectStart="trace('rotateStart')"
                        duration="250" 
                        autoCenterTransform="true"
                        applyChangesPostLayout="true" />

            <s:AddAction target="{noteGroup}"
                        effectStart="trace('add notes action')"/>
            <s:SetAction target="{noteGroup}" property="visible" />
            <s:RemoveAction target="{listGroup}" 
                        effectStart="trace('remove lists action')"/>

            <s:Rotate3D angleYFrom="90" angleYTo="0" 
                        effectStart="trace('rotateStart 2')"
                        duration="250" 
                        autoCenterTransform="true"
                        applyChangesPostLayout="true" />

        </s:Sequence>
    </s:Transition>

</s:transitions>

~~ UPDATE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~

我提到的解决方法是在两个状态中包含textarea,然后在最初未包含的状态下将visible设置为false:

<s:Group id="noteGroup" 
         includeIn="note,list"
         visible.list="false">

    <s:TextArea id="normalTextArea" />

</s:Group>

~~ UPDATE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
稍后(转换后)设置值(感谢Flextras),但在将光标放在textarea中之前,文本不可见。

列出更改处理程序代码:

protected function list1_changeHandler(event:IndexChangeEvent):void {
    content = (list.selectedItem as Note).content;
    currentState = "note";

    setTimeout(setText,1000);
}

private function setText():void {
    normalTextArea.text = content; // works but only on clicking into the textarea
}

这不起作用:

        protected function list1_changeHandler(event:IndexChangeEvent):void {
            content = (list.selectedItem as Note).content;
            normalTextArea.text = content;
            trace('1 text ='+normalTextArea.text); // contains content
            currentState = "note";
            normalTextArea.text = content;
            trace('2 text ='+normalTextArea.text); // contains content

            setTimeout(setText,1000);
        }

        // scenario 1
        private function setText():void {
            normalTextArea.text = content; // clicking into textarea it is empty
        }

        // scenario 2
        private function setText():void {
            normalTextArea.text = ""; // this does work but
            normalTextArea.text = content; // you have to click into textarea
        }

0 个答案:

没有答案