本文介绍了闪光AS3 XML CDATA大胆的标签呈现在的htmlText与嵌入字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是试图让闪光灯渲染动态文本字段大胆的文字与嵌入字体,用我从使用CDATA的XML文件导入数据。任何人都知道如何做到这一点?
XML文件:
<描述><![CDATA [在过去的两年中,< B> SUPERFAD< / B>一直密切合作过的< B> MARTIN代理< / B>以可视化的&LT原创作品; B>体育活动的< / B&取代。此役射灯的各种事件在自己的世界艺术家的极限运动员,用他们运动的工具来创造艺术]]&GT持久的作品;< /描述>
和AS3 code:
project_desc = myXML.projects.project [CP] .description.toUpperCase();
container.header.t_desc.htmlText = project_desc;
解决方案
总结要大胆文字的范围标签与类名。
<描述><![CDATA [在过去的两年中,<跨度类=myBoldText> SUPERFAD< / SPAN>曾...< /描述>
然后用样式表对象到ActionScript中设置样式。
VAR my_styleSheet =新的样式表();
变种N:对象=新的对象();
n.fontWeight ='大胆';
my_styleSheet.setStyle('myBoldText',N);
container.header.t_desc.styleSheet = my_styleSheet;
container.header.t_desc.htmlText = project_desc;
不要忘了导入样式表类!
进口的flash.text.StyleSheet;
在这里StyleSheet类
更多信息:的
I'm just trying to get flash to render bold text in a dynamic text field with an embedded font, using data I've imported from an xml file using CDATA. Anyone know how to do this?
XML File:
<description><![CDATA[ FOR THE PAST TWO YEARS, <b>SUPERFAD</b> HAS WORKED CLOSELY WITH THE <b>MARTIN AGENCY</b> TO VISUALIZE THE ORIGINAL WORKS OF <b>SPORT CAMPAIGN</b>. THE CAMPAIGN SPOTLIGHTS THE EXTREME ATHLETES OF THE VARIOUS EVENTS AS ARTISTS IN THEIR OWN WORLD, USING THE TOOLS OF THEIR SPORT TO CREATE LASTING WORKS OF ART]]></description>
and as3 code:
project_desc = myXML.projects.project[cp].description.toUpperCase();
container.header.t_desc.htmlText = project_desc;
解决方案
Wrap the text you want to be bold in span tags with a class name.
<description><![CDATA[ FOR THE PAST TWO YEARS, <span class="myBoldText">SUPERFAD</span> HAS WORKED...</description>
Then use a StyleSheet object to style it within your actionScript.
var my_styleSheet = new StyleSheet();
var n:Object = new Object();
n.fontWeight = 'bold';
my_styleSheet.setStyle('.myBoldText', n);
container.header.t_desc.styleSheet = my_styleSheet;
container.header.t_desc.htmlText = project_desc;
Don't forget to import the styleSheet class!
import flash.text.StyleSheet;
More info on the StyleSheet class here:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/StyleSheet.html
这篇关于闪光AS3 XML CDATA大胆的标签呈现在的htmlText与嵌入字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!