Skip to main content
September 22, 2006
Question

Tips on reading data into flash from an xml file please?!

  • September 22, 2006
  • 4 replies
  • 657 views
hi guys

I'm reading in nodes from an xml file into flash.
A node can consist of html code and various subnodes

here is an example

<fulltext>
<p>once upon a time there was a<b>bear</b></p>
<smallimage>bear.jpg</smallimage>
<p>this bear was <i>huge</i></p>
</fulltext>

I need to read this data into flash and then make it editable, in a visible format.
Can anyone give me a few tips on how to read in this data into textfields.

Particular problems i'm having include once i've read in the node above for example, how do i display the text in a textarea with the html code working e.g. showing bold, and how do i extract out the <smallimage> node and run a loadMovie command to display the .jpeg.


Any suggestions, tips and ideas would be really appreciated :-)

Many thanks for any responses.
This topic has been closed for replies.

4 replies

September 25, 2006
great many thanks for all your responses, i've got some good leads to go on, esp the embedding images in text fields idea.
Inspiring
September 22, 2006
Never needed to have a childnode inside of html. But when I need to include html and I don't want Flash to think that the html is child nodes I use CDATA tags around the html text.

How do you plan to let Flash know what the <smallimage> part means? AFAIK that isn't a standard HTML tag and certainly it isn't one that Flash understands.

<entry>
<smallImage srce="bears.jpg" />
<fulltext>
<![CDATA[
<p>once upon a time there was a<b>bear</b></p>
<p>this bear was <i>huge</i></p>
]]>
</fulltext>
</entry>

Perhaps something like the above is what I would design, but I'm not sure. It all depends upon exactly what you are trying to do.
Participant
September 22, 2006
You may want to consider looking at this... http://www.informit.com/guides/content.asp?g=flash&seqNum=393&rl=1
Flash can use HTML - (though basic) and render it in a text field - including images. You can even style it with CSS.
There are sample files for download and it's pretty easy to change what you want.
I used a simplier version of this on the following site: http://www.msnsportsnet.com/whywv
Hope it helps.
Be blessed!
September 22, 2006
Create a text field and give it an instance name e.g. tTextField.

set its html property to true. e.g. tTextField.html = true;

set the html text to use your node. e.g. tTextField.htmlText = yourNode

you could use an img tag to embed the image in the text field or maybe add bear.jpg as an attribute to your fulltext node. e.g. <fulltext image="bear.jpg"> then retrieve it from there.