更新时间:2023-12-05 09:17:46
而不是在MXML中声明的文本流,你可以以编程方式追加到一个字符串变量和 TextConverter.importToFlow()
。
Instead of a declarative text flow within MXML, you could programmatically update the text by appending to a string variable and reflowing with TextConverter.importToFlow()
.
例如:
在进入,从输入字段文本被追加与回流:
On enter, text from the input field is appended and reflowed:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955"
minHeight="600">
<fx:Script>
<![CDATA[
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.elements.TextFlow;
import mx.events.FlexEvent;
[Bindable]
public var text:String = "<p>Inline<br />TextFlow</p>";
protected function input_enterHandler(event:FlexEvent):void
{
text += input.text;
input.text = null;
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout />
</s:layout>
<s:TextInput id="input"
enter="input_enterHandler(event)" />
<s:RichEditableText editable="false"
selectable="true"
textFlow="{TextConverter.importToFlow(text, TextConverter.TEXT_FIELD_HTML_FORMAT)}"
buttonMode="true"
width="100%"
height="100%" />
</s:Application>