flash

Page 58

Chapter 3

Figure 3.3

Getting Your Feet Wet

The Output window with the new onLoad() method invoking

this.toString().

The really interesting bit of code is this line: trace(this.toString());

The trace() function is the easy part; it’s just putting the value of this.toString() in Flash’s Output window, as it would with any other value passed to it. The method call this.toString() is the bit of code returning your XML document, though. Here’s how it works. onLoad() is a method of recipeXML, so when you use the this keyword, you are referring to recipeXML. In fact, you could’ve just as easily said recipeXML.toString() instead of this.toString(). In general, XML.toString() (the toString() method for any XML object) returns your XML document in string form. Usually this format isn’t useful for anything more than a quick check of your document because the data is not separated in any way. Fortunately, that’s all you need right now to make sure your XML is all there.

Moving the Party to the Web To get this code working on the Web, you’re going to need get rid of the calls to the trace() function. In the first frame of your FLA, place a text box, and make it dynamic by selecting Dynamic Text from the Text Options panel. Next, select

45


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.