Recently when trying to load our Wordpress blog posts into flash we had some trouble displaying html text in a textField. The problem was that by default, if html data is loaded into a Flash text field, the field will render all paragraphs with indents. I ran into many possible solutions while searching for an answer, and tried everything from setting the xml property prettyIndent, to writing out my xml on one line out of desperation. In the end it took a combination of techniques to get rid of the indent.
The first one was to wrap the html data in the xml in a CDATA tag. This one makes total sense because html and xml’s syntax is so similar that flash needs to be told what’s xml and what’s actual data.
About the Project
New Line
]]>
The second step was to set the text field property condenseWhite to true.
After setting condenseWhite to true and having all the default styles removed from the text field, naturally, the next step is to apply css styles to the text field. I chose to load the css externaly and then apply it to the field.
color:#ffffff;
display:block;
text-indent:0;}
Once the file was created and saved, I loaded it and applied it to the textField.
{
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoadCSS);
var request:URLRequest = new URLRequest('styles.css');
loader.load(request);
}
private static function onLoadCSS(e:Event):void
{
css.parseCSS(e.target.data);
copy.styleSheet = Settings.css;
}
One thing to keep in mind when applying css styles to a text field is that if you have a text format already applied to the field the css will not be applied by flash.





