我只是想使用嵌入式字体在Flash动态文本字段中渲染粗体文本,使用我使用CDATA从xml文件导入的数据。有谁知道怎么做?
XML文件:
<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>
和as3代码:
project_desc = myXML.projects.project[cp].description.toUpperCase();
container.header.t_desc.htmlText = project_desc;
答案 0 :(得分:1)
使用类名将 span 标记中的文字换行。
<description><![CDATA[ FOR THE PAST TWO YEARS, <span class="myBoldText">SUPERFAD</span> HAS WORKED...</description>
然后使用 StyleSheet 对象在动作脚本中设置样式。
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;
不要忘记导入styleSheet类!
import flash.text.StyleSheet;
有关StyleSheet类的更多信息: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/StyleSheet.html