如何“追加” Flex和Flex移动项目中的html文本到文本区域以显示精灵和文本格式

发布于 2024-11-14 17:51:25 字数 808 浏览 6 评论 0原文

我正在使用消息类型的应用程序。有谁知道如何将 html 文本“附加”到 Flex 和 Flex 移动项目中的文本区域,或者有任何教程吗?具体来说,我如何在需要时将其内嵌到文本中“附加”精灵?一些简单的东西,比如:

用户名:这里有一些文字!

那么,有人有“附加”精灵或简单文本格式的经验吗?谢谢,我真的很困惑如何解决这些问题!

编辑: 根据下面的答案,有人建议它很简单......

textAreaInstance.htmlText += "<b>Username:</b> some text right here!";

但事实并非如此。您不能对文本区域执行 .htmltext 。你可以在文本字段上,所以我尝试了

var TF:TextField = new TextField();
TF.width = 200;
TF.height = 200;
TF.htmlText="Image in textfield: <img src='http://upload.pusha.se/3/HittaTidning_75.jpg' hspace='0' vspace='0'>";

//then i go to my text area instance and tried to add it the way you suggested                  
text_area_instance.text += TF;

所有这些显示的是 [object TextField]

I'm playing around with a messaging type of application. Does anyone know how, or of any tutorials on to "appending" html text to text areas in flex and flex mobile projects? And specifically how I could take that and basically "append" a sprite inline to the text when i need to? Something simple like:

Username: some text right here!

So, Anyone have any experience "appending" sprites or simple text formatting? Thanks I'm realy stumped on how to solve these issues!

EDIT:
Based on an answer below it was sugguested that it's as simple as...

textAreaInstance.htmlText += "<b>Username:</b> some text right here!";

But its not. you can't do .htmltext with a text area. you can on a text field, so i tried

var TF:TextField = new TextField();
TF.width = 200;
TF.height = 200;
TF.htmlText="Image in textfield: <img src='http://upload.pusha.se/3/HittaTidning_75.jpg' hspace='0' vspace='0'>";

//then i go to my text area instance and tried to add it the way you suggested                  
text_area_instance.text += TF;

All this displays is [object TextField]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冷血 2024-11-21 17:51:26

您所需要的只是 TextFieldhtmlText 属性:

tf.htmlText = "<b>Username:</b> some text right here!"

查看 此处了解详细信息。

至于嵌入精灵。类似的问题之前被问过。查看动态文本字段中的 Actionscript 问题

All you need is htmlText property of TextField:

tf.htmlText = "<b>Username:</b> some text right here!"

look here for details.

As for embing sprite. Similar question was asked before. take a look at Actionscript problem in Dynamic TextField

最佳男配角 2024-11-21 17:51:25

没有附加 html 文本的方法,因此您必须使用 += 附加 html 格式的内容:

    textAreaInstance.htmlText += "<b>Username:</b> some text right here!";

您可以通过这种方式在 TextArea 中嵌入显示对象:

    <fx:Script>
    <![CDATA[
        //display object class, what simply draws a recangle
        //you have to create a reference from this class, otherwise it won't work
        private var img:ImageStuff;


        protected function button1_clickHandler(event:MouseEvent):void
        {
            txt.htmlText = "<img src='ImageStuff' width='16' height='16'/>";
        }

    ]]>
</fx:Script>

    <mx:TextArea id="txt"/>
    <s:Button click="button1_clickHandler(event)" />

我不知道如何将显示对象嵌入到 Spark TextArea 中。

干杯

There is no method to append html text, so you have to use += appending your html formatted stuff:

    textAreaInstance.htmlText += "<b>Username:</b> some text right here!";

You can embed display objects in TextArea in this way:

    <fx:Script>
    <![CDATA[
        //display object class, what simply draws a recangle
        //you have to create a reference from this class, otherwise it won't work
        private var img:ImageStuff;


        protected function button1_clickHandler(event:MouseEvent):void
        {
            txt.htmlText = "<img src='ImageStuff' width='16' height='16'/>";
        }

    ]]>
</fx:Script>

    <mx:TextArea id="txt"/>
    <s:Button click="button1_clickHandler(event)" />

I don't know any way embedding display objects into spark TextArea.

Cheers

樱桃奶球 2024-11-21 17:51:25

对于移动设备,这有效(为我工作):

检查此链接
http://remotesynthesis.com/post.cfm /adding-html-text-to-a-flex-mobile-textarea

但使用 StyleableTextField 而不是 MobileTextField

For mobile this works (Worked for me):

Check this link
http://remotesynthesis.com/post.cfm/adding-html-text-to-a-flex-mobile-textarea

but use StyleableTextField instead of MobileTextField

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文