2011-05-20 51 views
0

我有AS3创建的文本字段为这样的:(theDesc是通过函数传递的参数)AS3的htmlText是示出标签

var productDescTxt:TextField = new TextField(); 
productDescTxt.htmlText = theDesc; 
productDescTxt.multiline = true; 
productDescTxt.wordWrap = true; 
productDescTxt.embedFonts = true; 
productDescTxt.setTextFormat(productInfoTF); 
productDescTxt.x = 10; 
productDescTxt.y = productNameTxt.y+productNameTxt.textHeight+15; 
productDescTxt.width = 325; 
holder.productsTab.addChild(productDescTxt); 

theDesc是HTML内容与字符编码:

例如:

<p><strong>6.1 oz cotton at an affordable price</strong></p> 

问题是textField正在显示每个字符。 <p><strong>

是否有任何额外的编码需要完成我的目的?

+0

什么theDesc看起来像在您的设置呢? – locrizak 2011-05-20 13:06:11

+0

这是作为一个字符串传递完全像我的例子。 – rson 2011-05-20 13:13:10

+0

这样的<p> <强> 6.1盎司棉价格合理< /强> </p >? – locrizak 2011-05-20 13:16:39

回答

0

查看此页的来源,找到这一行:

<WEARE>

这个答案框做几乎一样的闪光文本字段的htmlText功能的东西。
更多关于htmlText posibilieties在闪光灯:TextField – available html tags

0

看起来像你从一些服务器得到它,不是吗?您需要手动更改&lt;<,&gt;>。例如。在PHP中(如果你的应用程序的服务器部分是用PHP编写的),那么html_decode()函数将取代所有你。我不知道在AS3中有类似的功能。

但是,我可以告诉你个小窍门:

var tempField:TextField = new TextField(); 
tempField.htmlText = theDesc; 
var productDescTxt:TextField = new TextField(); 
//... 
productDescTx.htmlText = tempField.text; 
holder.productsTab.addChild(productDescTxt); 

,会为你做html_decode()!希望有所帮助!