如何添加动态文本的textFlow内标签 [英] How to add dynamically text and tags inside textFlow

查看:98
本文介绍了如何添加动态文本的textFlow内标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<s:RichEditableText editable="false" styleName="chatWin" height="550" width="100%">
        <s:textFlow>
            <s:TextFlow>
                    <s:p>Inline<s:br />TextFlow</s:p>
            </s:TextFlow>
        </s:textFlow>
</s:RichEditableText>

我要添加此&LT; S:P&GT; 标签动态,从而使聊天......我已经试过这样:

I want to add this <s:p> tag dynamically, thus making a chat...i've tried this:

var p:p = new p();

但这不起作用

but this don't work

推荐答案

而不是在MXML中声明的文本流,你可以以编程方式追加到一个字符串变量和<一个回流更新文本href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flashx/textLayout/conversion/TextConverter.html#importToFlow%28%29"相对=nofollow> 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>

这篇关于如何添加动态文本的textFlow内标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆