Author: Matt Slaybaugh
Date: October 25, 2006
Level: Beginner
Bullseye is a game in which the player uses the mouse to aim a bow and fire an arrow. In this tutorial, you will change the values of some of the variables in an external XML file used in the game.
- Using a text editor
- Any text editor, such as Notepad or BBEdit
- labels.xml
- myglife_archery.swf
The Bullseye game uses text gathered from an external XML file.
The Bullseye game uses an XML file, named labels.xml to store the text used in the game. To change the text (for example, if you were to create a version in another language) you only need to update this file and do not need to recode the application.
XML stands for Extensible Markup Language and is very similar to HTML. You can edit XML files as you would HTML files, with any text editor.
Below is the full contents of the file labels.xml.
<?xml version='1.0'?>
<labels>
<score name='SCORE'/>
<angle name='ANGLE'/>
<speed name='SPEED'/>
<windspeed name='WIND SPEED'/>
<practice name='PRACTICE'/>
<compete name='COMPETE'/>
<trails name='TRAILS'/>
<bow name='BOW'/>
<forces name='FORCES'/>
<reset name='RESET'/>
<shotsleft name='SHOTS LEFT'/>
<archerypractice name='ARCHERY PRACTICE'/>
<archerycompetition name='ARCHERY COMPETITION'/>
<closebutton name='CLOSE'/>
<yourscore name='YOUR SCORE'/>
</labels>
There are fifteen places in the Bullseye game where text appears on the screen: In the XML code above, the labels are defined and given unique, descriptive titles (eg. score, angle) and values (eg. 'SCORE', 'ANGLE')
The titles are what the Flash application will be looking for, so if we change them the game won't work properly. The values are the strings of text that will appear in the game.
- Open labels.xml in your text editor.
- If you were to host this game on a Spanish-language site, you would want the text to be in Spanish. Change the text of the first label ('score') to "Cuenta"
- The line should look like this:
<score name='Cuenta'/> - Open myglife_archery.swf in a browser. You should see that the 'score' label now reads "Cuenta".
- Change the rest of the labels to whatever you like.
