我很想看看有没有人能解释一下Spark RichEditableText组件中一些奇怪的文本渲染行为。
<?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"
creationComplete="handleApplicationCreationComplete()"
>
<fx:Script>
<![CDATA[
import flashx.textLayout.conversion.TextConverter;
private static const DATA:Array =
[
"First sentence. This is a test of text rendering. How's it look?",
"Let's see if this actually works correctly.",
"Add some variety with the <b>bold</b> tag...",
"Throw in a <a href='http://www.example.com'>link</a> as well!",
"Well?! Does it work as expected? I think not..."
];
private var currentIdx:int;
protected function handleNextClick():void
{
currentIdx++;
if(currentIdx >= DATA.length)
currentIdx = 0;
display(currentIdx);
}
protected function handleApplicationCreationComplete():void
{
currentIdx = 0;
display(currentIdx);
}
private function display(idx:int):void
{
contentDisplay.textFlow = TextConverter.importToFlow(DATA[idx], TextConverter.TEXT_FIELD_HTML_FORMAT);
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout />
</s:layout>
<s:VGroup width="100">
<s:RichEditableText id="contentDisplay"
width="100%"
enabled="false" mouseEnabled="false"
editable="false" focusEnabled="false"
/>
</s:VGroup>
<s:Button label="Next" click="handleNextClick()" />
</s:Application>上面的应用程序只是浏览DATA数组中的五个句子(每次按下Next按钮时)。无论出于什么原因,RichEditableText组件在设置新内容之前都不会完全重置其视图(通过清除以前的文本)。据我所知,这个错误的渲染以某种方式基于行数和相对宽度的组合。我还发现,如果将RichEditableText组件的width属性设置为绝对值(比如100),而不是相对的(percentage,100%),文本就会正确呈现。
据我所知,这种行为是无意的,实际上是一个bug。



发布于 2012-01-21 01:21:53
没有解决方案,这是框架中的一个错误...
发布于 2012-09-18 17:28:05
这是4.1 SDK中的一个错误。要解决此问题,您可以清除RTE,然后在subsiquent框架上更新它。
callLater(function workAround(richEditableText:RichEditableText, updateText:String):void
{
richEditableText.text = updateText;
}
, [ myRichEditableTextComponent, myNewMessageText ]);只需将此代码放在您之前更新RET的位置,并传递组件和新文本。如果你使用的是文本流,这应该是一样的,只要用流替换文本和文本字符串即可。
https://stackoverflow.com/questions/5158443
复制相似问题