nwebb banner

   hometutorialsworkphotosflash

 Recommended
 
 Tutorials


Tutorial details: Loading External XML formatted Content into Flash MX 2004
Difficulty Level: Intermediate
Requirements: Flash MX 2004
Assumed Knowledge: Having read my "Cascading Style Sheets in MX2004" tutorial
File(s) to Download: xmlhtmlcss1.zip
Online Example: None




Loading External XML formatted Content

Welcome grasshopper.

This tutorial is ideally used in addition to my "CSS in Flash" tutorial and covers topics such as loading external XML-formatted text into Flash and using external CSS to display that text within the TextArea component. These are questions I've been seeing on the forums of late, and so I hope it will answer some of your questions.

First off, we're going to create some XML formatted data to bring in to our movie. Open up your favourite text editor and paste the follow text in to it:

<drunken>This is some drunken text</drunken>
<monkey>This is some monkey text</monkey>
<snake>This is some snake text</snake>
<dragon>This is some dragon text</dragon>
For those of you unfamiliar with XML, notice that our XML tags look very similar to standard HTML tags - the difference being that we can create the tag names ourselves. It is of course more appropriate to name our tags with descriptive names such as "header", "byline" and so on, but for the sake of this tutorial I've gone with kung-fu related names. As with variables, there are certain rules to naming your tags, such as not including spaces in those names. You can use mixed case and you can use underscores - at least in Internet Explorer, but I would generally advise against it. Keep your names short, simple, descriptive and all lower case and then you can't go far wrong. You should also note that all opening tags must have a corresponding closing tag.

Our file above will work, but it's standard practice to enclose all our same-level tags (nodes) in a single root node, and so that's what we'll do. Amend the above code to look like this:

<kungfu>
	<drunken>This is some drunken text</drunken>
	<monkey>This is some monkey text</monkey>
	<snake>This is some snake text</snake>
	<dragon>This is some dragon text</dragon>
</kungfu>
Save the file as "kungfu.xml"
Note: the file can also be saved as kungfu.html as long as you load it into the Flash XML object as kungfu.html at the appropriate time.

Part: 1 2 3 4 5