Flash AS3 XML CDATA BOLUD Tags Rendering in HTMLTEXT con un font incorporato
-
15-11-2019 - |
Domanda
Sto solo cercando di ottenere il flash per rendere il testo in grassetto in un campo di testo dinamico con un font incorporato, utilizzando i dati che ho importato da un file XML utilizzando CDATA.Qualcuno sa come fare questo?
File 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>
.
e AS3 Codice:
project_desc = myXML.projects.project[cp].description.toUpperCase();
container.header.t_desc.htmlText = project_desc;
. Soluzione
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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow