maguskrool
Technical User
Hi.
I have a dynamic text field on the Stage, named txt01. I'm trying to load text into it, from a .xml file (text_01.xml) and have it formatted through an external .css file (css_01.css) that I'll load into Flash as well. I've tried checking and unchecking the "render text as html" option but the results were the same.
When I test the movie, I see the bold and italic text correctly, but none of the other formatting described in the .css. Using getStyleNames displays the correct styles defined in css_01.css, so I know they are loaded correctly.
I've seen the example described here:
and it works mostly like mine, except it loads the text from a .txt and not a .xml file, and there the css works perfectly. I do need to use .xml however, so trying a .txt is not an option. Any clues on what's wrong and how I might get it to work?
Thank you for your time.
CODE:
I have a dynamic text field on the Stage, named txt01. I'm trying to load text into it, from a .xml file (text_01.xml) and have it formatted through an external .css file (css_01.css) that I'll load into Flash as well. I've tried checking and unchecking the "render text as html" option but the results were the same.
When I test the movie, I see the bold and italic text correctly, but none of the other formatting described in the .css. Using getStyleNames displays the correct styles defined in css_01.css, so I know they are loaded correctly.
I've seen the example described here:
and it works mostly like mine, except it loads the text from a .txt and not a .xml file, and there the css works perfectly. I do need to use .xml however, so trying a .txt is not an option. Any clues on what's wrong and how I might get it to work?
Thank you for your time.
CODE:
Code:
//FLASH, AS2
//1ST FRAME
var style_sheet:TextField.StyleSheet = new TextField.StyleSheet ();
var my_xml:XML = new XML ();
my_xml.ignoreWhite = true;
//
style_sheet.onLoad = function (success:Boolean):Void {
if (success) {
txt01.styleSheet = style_sheet;
my_xml.load ("text_01.xml");
} else {
trace ("Error loading CSS.");
}
};
//
my_xml.onLoad = function (success:Boolean):Void {
if (success) {
txt01.text = my_xml;
} else {
trace ("Error loading XML.");
}
};
//
style_sheet.load ("css_01.css");
//XML (text_01.xml)
<?xml version="1.0" encoding="UTF-8"?>
<mytext>This <biggy>text</biggy> should be<b>bold</b> or <i>italic</i>, please.</mytext>
//CSS (css_01.css)
.biggy{
font-size: 36px;
color:#006600;
}
b {
font-size: 16px;
color:#336633;
}