PDA

View Full Version : XML -> Flash, text formatting


roddox
01-13-2003, 07:02 AM
Hello all,

My project is a standalone projector which imports its data in from XML data files and spits the text out into dynamic text fields on the stage. That bit works fine.

What I want to be able to do seems pretty simple: add text formating to this data. For example bold, italic, inserting line breaks etc etc. I really have no idea, but I do know that I want to keep the XML file pretty simple because others will be editing the content later on ( it seemed possible that I could throw a whole lot of HTML inside a CDATA tag or even forget XML and use LoadVars with URLencoded data but I dismissed doing that for the above reason.) I'd prefer my data to be simple XML and all the complexity to be on the actionscript side of things..
I'm sure someone has needed to do this before but i'm clueless... any ideas or example scripts on how to attack this???:confused:

any help appreciated...cheers :)
r.

jimburton
01-13-2003, 12:56 PM
welcome roddox :)

best to do this at the same time as parsing your xml and writing the content to textfield objects, using textformat objects eg:



// set up as many textformat objects as you need before
// parsing your xml etc
boldItalic = new TextFormat();
boldItalic.bold = true;
boldItalic.italic = true;

// now in the middle of your xml parsing loop...
display.text = content;//content is some stuff you got from your xml doc
displayText.setTextFormat(boldItalic);

roddox
01-14-2003, 12:50 AM
Thanks Jim! I've put that into my code and it works fine, thanks for your help.
r.