Lesson 12. Using XML with Flash

Imagine what it would be like if every electrical appliance in your home had a different type of plug. Chances are you'd end up putting most of those gizmos back in the cupboard and doing the task manually. Or what if none of the screwdrivers or wrenches in your tool shed even came close to fitting the screws, nuts, and bolts that hold stuff together? Fortunately, neither scenario is likely because people figured out long ago that by creating products according to guidelines, or rules of standardization, they could have far more productive societies.

In essence, standards facilitate linkages between disparate itemsbattery and flashlight, Macromedia Flash and multi-user game server, and so on. And on the Web, where tons of data is transferred every second, having a standardized way of moving data among systems is essential. The powerful and easy-to-use XML has become one standard.

The simple chat application that you will script in this lesson shows you how to connect a Flash application to an XML socket server.

graphics/12inf01.gif

In this lesson, we'll introduce you to the XML format as well as show you how to use the XML class and the XMLSocket class in Flash. By lesson's end, you will have made Flash talk to ASP pages for user login and registration, and you will have created a very simple real-time chat application using a socket server.

WHAT YOU WILL LEARN

In this lesson, you will:

  • Learn about the XML format

  • Create new XML objects

  • Learn how to parse an XML document

  • Send and load XML from the server

  • Use methods, properties, and events of the XML object

  • Learn about the XMLSocket class and socket servers

  • Build a simple real-time chat application

APPROXIMATE TIME

This lesson takes approximately one and one half hours to complete.

LESSON FILES

Media Files:

AddUser.asp

UserLogin.asp

XMLExample.mdb

InstallElectroServer.exe

ElectroServer.as

Wddx.as

WddxRecordset.as

Starting Files:

Lesson12/Assets/loginRegister1.fla

Lesson12/Assets/Chat1.fla

Completed Projects:

loginRegister2.fla

Chat2.fla