AS3 htmlText 显示标签
我有一个用 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 显示每个字符。
等。
我这边是否需要进行任何额外的编码?
I have a textfield created with AS3 as thus: (theDesc is a parameter passed through a function)
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
is html content with character encodings:
ex:
<p><strong>6.1 oz cotton at an affordable price</strong></p>
the problem is the textField is displaying every character. <p><strong>
etc.
Is there any extra encoding need done on my end?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来你是从某个服务器获得的,不是吗?您需要手动将
<
更改为<
,将>
更改为>
。例如,在 PHP 中(如果应用程序的服务器部分是用 PHP 编写的),有html_decode()
函数将为您替换所有内容。我不知道AS3中有类似的功能。但是,我可以告诉你一个小技巧:
这将为你做
html_decode()
!希望有帮助!Looks like you get it from some server, don't you? You need to change
<
with<
,>
with>
manually. E.g. in PHP (if server part of your app is written on PHP) there'shtml_decode()
function which will replace all for you. I don't know of similar function in AS3.But, I can advise you small trick:
that will do
html_decode()
for you! hope that helps!查看此页面的源代码并找到这一行:
这个答案框的功能几乎与 flash textField htmlText 功能相同。
有关 Flash 中 htmlText 可能性的更多信息: TextField –可用的 html 标签
view source of this page and find this line:
<weare the something>
this answer box does almost the same as flash textField htmlText function.
more about htmlText posibilieties in flash: TextField – available html tags
您不希望 htmlText 值包含 HTML 特殊字符,请转义它们,请参阅此答案 从 Flex 中的字符串中转义(解码)HTML 字符
You don't want HTML special characters for the htmlText value, escape them see this answer Unescape (decode) HTML characters from string in Flex