Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format text in flash from XML file - help!

Status
Not open for further replies.

oliverlubin

Programmer
Dec 10, 2002
1
US
ok, so i have a "well-formed" xml file with various information in it.

xml file snippet/example:
------------------------------------------
<section name=&quot;Introduction&quot;>
<part>Paragraph one of the introduction.</part>
<part>Paragraph two of the introduction.</part>
</section>
<section name=&quot;Setup&quot;>
<part>Paragraph one of the setup.</part>
<part>Paragraph two of the setup.</part>
<part>Paragraph three of the setup.</part>
</section>
------------------------------------------

ive managed to import the xml into flash and display it in a dynamic text field. what i want to do is format the text in multiple ways. for example, i want the &quot;section names&quot; to be size 12 and bold and a certain color. i want the paragraphs under each section to be size 11, non-bold and another color. once the &quot;page&quot; is formatted properly i already have a movieclip set up to scroll it up and down.

how do i format individual nodes as they are written into the &quot;main body&quot; of the dynamic text field. i was thinking i could create a new field for each new node and format each one depending on it's attribute name (is that the correct terminology). but i couldnt figure out how to make each one fit the amount of information properly without setting the size of the dynamic filed first. (if i want to stack them on top of eachother (bottom of one to top of the next), the actual size of the fields need to change based on how much text is in them.) i should mention that im doing this for 15 different xml files (and 15 different flash movies) that are formatted the same way but do not necessarily have the same &quot;section names&quot; for example. so one may be called &quot;introduction&quot;, but on the next one it could not even include an &quot;introduction&quot; section at all.

any help would be greatly appreciated. im kinda stumped right now.

thanks,
-Oly
 
Load your data into flash using the loadvars method
mydata = new LoadVars();
mydata.onLoad = addItems;
function addItems() {
message.multiline = true;
message.wordWrap = true;
message.type = &quot;dynamic&quot;;
message.background = true;
message.backgroundColor = &quot;0x87cefa&quot;;
message.border = true;
message.borderColor = &quot;0x000000&quot;;
message.html = true; message.htmlText = myData.text;
}
mydata.sendandload(&quot;full url to data&quot;);


Font size , color etc can be set in a similar manner. Refer to the actionscipt dictionary full a full list of methods and properties. I use this method to send and recieve data via php/mysql. Works just as well with xml. Add scrollbars if needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top