如何“附加"html文本到flex和flex移动项目中的文本区域以显示精灵和文本格式 [英] How to "append" html text to text area in flex and flex mobile project to display sprite and text formatting
问题描述
我正在尝试一种消息传递类型的应用程序.有谁知道如何将 html 文本附加"到 flex 和 flex 移动项目中的文本区域的任何教程?尤其是当我需要时,我如何才能做到这一点,并且基本上附加"一个内联精灵到文本中?一些简单的东西,比如:
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:
用户名:这里有一些文字!
那么,任何人都有附加"精灵或简单文本格式的经验吗?谢谢 我真的很困惑如何解决这些问题!
So, Anyone have any experience "appending" sprites or simple text formatting? Thanks I'm realy stumped on how to solve these issues!
根据下面的答案,有人建议它很简单...
Based on an answer below it was sugguested that it's as simple as...
textAreaInstance.htmlText += "<b>Username:</b> some text right here!";
但事实并非如此.你不能用文本区域做 .htmltext
.你可以在文本字段上,所以我试过
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;
所有显示的是[object TextField]
推荐答案
没有方法可以附加 html 文本,因此您必须使用 += 附加 html 格式的内容:
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!";
您可以通过这种方式在 TextArea 中嵌入显示对象:
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)" />
我不知道有什么方法可以将显示对象嵌入到 spark TextArea 中.
I don't know any way embedding display objects into spark TextArea.
干杯
这篇关于如何“附加"html文本到flex和flex移动项目中的文本区域以显示精灵和文本格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!