【问题标题】:Flex 4 text rendering in s:RichEditableText components:RichEditableText 组件中的 Flex 4 文本渲染
【发布时间】:2011-03-01 18:01:59
【问题描述】:

我很想知道是否有人可以对 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)而不是相对(百分比,100%),则文本会正确呈现。

据我所知,这种行为是无意的,实际上是一个错误。

【问题讨论】:

  • 我相信这对我来说是正确的。或者至少我没有看到任何明显的错误。您可以发布您看到的不良行为的屏幕截图吗?您使用的是什么 SDK 版本?
  • 也没有发现任何奇怪的代码行为。我还会检查 Flash 播放器版本。
  • 我使用的是 Flex SDK 4.1,根据 Adob​​e 的网站,我的 Flashplayer 版本是 10,1,102,64。我怀疑它与播放器版本有什么关系。我还添加了截图
  • 我想补充一点,我在使用 RichEditableText 时得到了相同的行为。我已将文本框宽度设置为 100%,将 heightInLines 设置为 NaN。第一行已更新,但后续行包含旧文本。我正在使用 SDK 4.5。

标签: apache-flex flex4


【解决方案1】:

没有解决方案,这是框架中的一个错误......

【讨论】:

    【解决方案2】:

    这是 4.1 SDK 中的一个错误。要解决此问题,您可以清除 RTE,然后在后续帧上更新它。

    callLater(function workAround(richEditableText:RichEditableText, updateText:String):void
    {
        richEditableText.text = updateText;
    }
    , [ myRichEditableTextComponent, myNewMessageText ]);
    

    只需将此代码放在您之前更新 RET 的位置并传递组件和新文本。如果您使用的是文本流,这应该同样有效,只需将文本和文本字符串替换为流。

    【讨论】:

      猜你喜欢
      • 2017-12-04
      • 2010-12-20
      • 2013-06-22
      • 2011-12-23
      • 1970-01-01
      • 2017-12-17
      • 1970-01-01
      • 1970-01-01
      • 2011-09-08
      相关资源
      最近更新 更多