vasconcelosvcd
vasconcelosvcd

Reputation: 119

Change a color on flash importing an html from XML

I'm getting an html text from a XML and I have to show a text in flash, I was able to print and the flash has interpreted the HTML but anything changed.

I already use the text.htmlText

EDIT:

this is how i get my HTML text...

tick.ticker.htmlText = EBFlash.browser.data("D_TICKER").texto

.texto returns

<p> LINHA 020<span style="color:#a52a2a;">-INTERBAIRROS</span> II (HOR&Aacute;RIO) - ALTERA&Ccedil;&Atilde;O DE HOR&Aacute;RIOS EM DIAS &Uacute;TEIS A PARTIR DE <b>13/01/2014 </b>- WWW.URBS.CURITIBA.PR.GOV.BR</p>

so the flash interprate the HTML but dont make the color changes or anything else.

Upvotes: 0

Views: 212

Answers (2)

p4tch
p4tch

Reputation: 81

If you aren't already try something like...

yourTextFieldName.htmlText = xml.node.text()[0];

I'm a little confused as to what your actual problem is. If you could show us some code it would be easier to understand.

EDIT: The code you pasted below doesn't look like properly formatted flash html. Flash is only capable of very basic styling. Read here...

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#htmlText

If you have access to the source try something like...

< font color="#a52a2a">-INTERBAIRROS </font>

You can also use style sheets in flash... http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/StyleSheet.html

Upvotes: 0

Ribs
Ribs

Reputation: 1505

You need to make a stylesheet in Flash to actually style the span tags. In the text that was returned from your xml you're going to need to replace the style attribute with a class name first, then style it:

var myText:String = EBFlash.browser.data("D_TICKER").texto;
myText = myText.replace( 'style="color:#a52a2a;"', 'class="colorText"' );

That should make your text look like:

<p> LINHA 020<span class="colorText">-INTERBAIRROS</span> II (HOR&Aacute;RIO) - ALTERA&Ccedil;&Atilde;O DE HOR&Aacute;RIOS EM DIAS &Uacute;TEIS A PARTIR DE <b>13/01/2014 </b>- WWW.URBS.CURITIBA.PR.GOV.BR</p>

then:

import flash.text.StyleSheet;
var myStyleSheet:StyleSheet = new StyleSheet();
myStyleSheet.setStyle( '.colorText', { color: '#a52a2a' } );
tick.ticker.styleSheet = myStyleSheet;

tick.ticker.htmlText = myText;

The BOLD tags will not work unless the font you are using has a bold option. You can also replace the BOLD tags with another set of span tags and a unique class name and style them to be bold the same way the color is being styled above.

Upvotes: 3

Related Questions