0

我有一个使用 AS3 创建的文本字段,如下所示:(theDesc 是通过函数传递的参数)

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>等等

我是否需要进行任何额外的编码?

4

3 回答 3

0

查看此页面的源代码并找到此行:

<穿的东西>

此答案框与 flash textField htmlText 功能几乎相同。
更多关于 Flash 中 htmlText 可能性的信息:TextField – 可用的 html 标签

于 2011-05-20T13:25:18.403 回答
0

您不希望 htmlText 值的 HTML 特殊字符,转义它们看到这个答案Unescape (decode) HTML characters from string in Flex

于 2012-08-03T08:52:51.810 回答
0

看起来你是从某个服务器获得的,不是吗?您需要手动更改&lt;with <, &gt;with 。>例如,在 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()为你做的!希望有帮助!

于 2011-05-20T14:37:22.797 回答