XML

XML is the fastest and easiest way to load external data into Flash. You could take a whole class just on XML, so we will focus mainly on how to read in the file in ActionScript and use it to create scrolling message. In order to keep the example short, and to focus on the use of XML, we will start with the scrolling messages project from the lesson on arrays. Instead of putting the messages in an array, the messages are in an external XML file.

Get Adobe Flash player

XML is a file that uses tags in a way similar to html. There are three important things to remember:

  • Every tag must be closed;
  • The tags are case sensitive;
  • Numbering always starts with 0.

You can make up tag names to suit your application. An XML file with some messages is shown here. You can copy and past this to create a file or open messages.xml and save it to the same folder where you save your Flash movies.

<?xml version="1.0" encoding="utf-8"?>
<file>
<item>Good job!</item>
<item>Keep up the good work!</item>
<item>Way to go!</item>
<item>Excellent!</item>
</file> 

NEXT: XML Messages