Game Development Reference
In-Depth Information
10
XML AND DYNAMIC CONTENT
CHAPTER OUTLINE
Bringing Data In: Understanding the URLLoader Class
157
XML 158
E4X 158
Crossword Puzzle 159
The CrosswordTile Class 163
The CrosswordClue Class 167
The CrosswordPuzzle Class 168
Content Is a Two-Way Street: A Crossword Builder
179
Sending Data Back Out 180
One More Example: XML versus Flash Vars
181
Summary
182
Many Flash games are self-contained SWF files. They don
'
tload
any additional files in, and they don
t send any type of data out.
However, this closed architecture prohibits a number of scenarios
such as
￿
'
Externalized content (such as a puzzle data or even a game
copy)
￿
The ability to save to a public high-score table
￿
Localization to other languages
￿
Level editors and user-generated content
In this chapter, we
ll explore how features like these can be
implemented using a variety of features in ActionScript.
'
Bringing Data In: Understanding the
URLLoader Class
The core component behind sending and loading basic text, XML,
and binary data is the URLLoader class. It takes only a few lines of
code to load some data and begins working with it. Consider the
following example:
var loader:URLLoader = new URLLoader(new URLRequest( " config.txt " ));
loader.addEventListener(Event.COMPLETE, onTextLoad, false,
0, true);
 
 
Search Nedrilad ::




Custom Search