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()!希望有所幫助!