For this example we are going to keep this pretty simple.  So we are going to create an XML document which will house the content for our news articles.  This will contain 5 articles, each with 4 properties:

·         Headline - The title of the news article

·         Copy - The body of the news article.

·         Image -  An image that will display with the article

·         Hyperlink (link) - A link to the full article, or more information

 


So let's get into some XML.

 

  1. Create a new .xml file in any editor you choose.  You can start by creating a text file and just changing the extension to .xml.
  2. Name the file "features.xml".
  3. Copy and paste the code below into the XML

 <?xml version="1.0" encoding="utf-8"?>

<features>

      <feature enabled="true">

            <headline>HEADLINE 1</headline>

            <copy>Here goes some copy you can probably put html text in here as long as its escaped</copy>

            <image>images/1.gif</image>         <link>http://www.sandboxcommunications.com</link>

      </feature>

      <feature enabled="false">

            <headline>Feature 2</headline>

            <copy>Lorem ipsumn dolomet sit</copy>

            <image>images/2.gif</image>

            <link>http://search.mustcodemore.com</link>

      </feature>

      <feature enabled="true">

            <headline>MustCodeMore</headline>

            <copy>More mustcodemore.com, more</copy>

            <image>images/3.gif</image>

            <link>http://www.mustcodemore.com</link>

      </feature>

      <feature enabled="true">

            <headline>Feature 4</headline>

            <copy> Lorem ipsumn dolomet sit amore dit amore.</copy>

            <image>images/4.gif</image>

            <link>http://www.google.ca</link>

      </feature>

      <feature enabled="true">

            <headline>Feature 5</headline>

            <copy>Borem Bpsumn Bolomet Bit Bmore Bit Bmore.</copy>

            <image>images/5.gif</image>

            <link>http://www.hp.ca</link>

      </feature>

      <feature enabled="true">

            <headline>Feature 6</headline>

            <copy>asdf j lakj. This is about feature six.  Man </copy>

            <image>images/6.gif</image>

            <link>http://www.yahoo.ca</link>

      </feature>

</features>

 

So let's take a look at this to make some sense of it.  Let's look at ONE article only to understand how this works.

 

Firstly lets look at the very top this line:

            <?xml version="1.0" encoding="utf-8"?>

 

This line is basically a declaration to tell whatever is calling it that it is, in fact, an XML Document.  It stipulates a version and the content encoding type.  Its required for all xml documents.

 

<features>

 

This is the beginning tag of our collection of features.  If you look at the bottom of the XML Document you will also see that this has a closing tag like : </features> Everything inside these two tags is considered a part (or element of) the features collection.

 

Now lets actually look at a feature and its properties:

 

<feature enabled="true">

            <headline>HEADLINE 1</headline>

            <copy>Here goes some copy you can probably put html text in here as long as its escaped</copy>

            <image>images/1.gif</image>

            <link>http://www.sandboxcommunications.com</link>

      </feature>

 

So above is one feature.  Notice how it's made up of a hierarchy of tags.  Starting with the <feature enabled="true"> tag.  This tag also has a property "enabled" and its set to true.  This tells our movie that this feature is available to use.  If you switch that to "false" the feature will effectively be disabled and will not show up in the flash movie.

 

Under that tag there are our tags that define the content of the features.  We have :

 

<headline> This is where you put the title of the feature.

 

<copy> Put the actual text content of the feature or article in here.  You could use HTML Text if it's escaped (or encoded) but you should be careful as flash does not always parse html as expected.

 

<image> This is the RELATIVE path to the image file from the page hosting your flash movie.  Since the page will be in the ROOT directory ("FlashNewsListing") we must specify the path to the images folder and the image name.

 

<link> is the hyperlink we want this article to link to.

 

And this is just repeated for the number of news articles, or features we have.

 

So once that’s all set up just save and close the xml document.   If you have Visual Studio or another XML Editor you can also probably check the document for errors, which is quite useful but beyond the scope of this article.

Now lets move on to the next step...