• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Creating XML

The key to creating XML in Flash is that creating a node in an XML object is a two-step process. First, an element must be created. Then it must be placed. You can't do both at once. Let's begin, and you'll see exactly what I mean.

Creating the Object

1.
Create a new Flash file called xml2.fla.

2.
Click on the frame in layer 1 and open its Frame Actions panel.

3.
Enter this code:

// create XML object 
screenplayXML = new XML();

// create screenplay element/node
screenElement = screenplayXML.createElement("screenplay");

// place the screenplay element
screenplayXML.appendChild(screenElement);
screenElement.attributes.title = "Three Days of the Condor";

// display
trace(screenplayXML.firstChild);

4.
Test the movie. The result should be

<screenplay title="Three Days of the Condor" /> 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint