alt
Advertisement
Online Training
Career Series
Exforsys
Exforsys arrow Tutorials arrow XML arrow Working with XML in Flash
Site Search


Working with XML in Flash
Article Index
Working with XML in Flash
Variables and Visual Elements

How are Visual Elements Handled?

Flash is probably one of the easiest software programs to handle. To create a flash movie all you have to do is open and click on "create movie" and provide everything required. For visual elements we need dynamic text fields.

Everything else depends on the action script, which is the key element for bringing in the XML into a flash movie. The first thing we would do is to tell Flash that XML will be used in the movie. What is done here is that a variable is created inside the flash movie which is of XML to understand the XML which will be integrated with the movie. The variable headline will have properties which can identify a XML document.

The next step is to load the XML document. A variable called the variable headline is used to associate the script, and the program which will be used to run the script. The correct path to the XML file is written in the headline. If flash is not able to find this path then the movie will not play.

So it is very important that flash find this path to play the movie. Finally, to check if everything is correct in the program, the only way to validate is if the flash movie is playing. If the movie plays then the visual elements have been handled well and also correctly. It also means that the published variable can be executed.

What is the Publish Variable?

The main function of the published variable is to parse the content from the XML document. The flash software examines the relationship to see where the content appears within a specified tag. XML data is usually grouped with other data, having a sort of parent child relationship.

Elaborately one field will be the main tag for the entire documents which will be dependant on the main tag, and the main tag which is the Broadcast tag is the parent here.

How do we load XML into Flash?

While loading a XML document into Flash, the important thing to figure out is how we load the document, and what commands need to be given so that the document gets loaded successfully. There are two main functions which can be spoken of while loading a XML document into Flash. One would be a function which will already be present, and which will probably need to be called on its own.

The other is the callback function. The call back function has to be defined by you, and should be able to respond when called by Flash and when such circumstances arise that require this function to be called.

In XML the Event is Called the Onload Event

All these functions are used in XML. The XML instances are created by using the class and object, and a construct element in flash that helps you manage XML. If XML has to work in Flash then the XML instances have to be used. So first of all before loading an XML into flash, an XML instance has to be created in Flash. While creating an XML instance there is an option where you can pass the XML string to the XML constructor. This string will have an XML which will be defined with the XML instance that has been created.

Once you have successfully defined the instance, then you can define the onload and callback functions. The callback function always has to be made onload. Using this decides when to call for a callback function, and that is after the XML content is loaded and parsed. In addition to this, a success element is also passed into the document which will pass if the loading has been successful. This will let you know if XML has been loaded or not.

XML has to load in flash and this process cannot be immediate, and it also takes time. Sometimes several seconds translate to Flash frames before XML is accessible to the XML instance. This also means that an attempt to access information within the same script while loading will be a failure.

That is if this whole process occurs in a single onload function. An onload function is usually defined in the same script like everything else, and also this onload function is not called upon unless XML is fully loaded and parsed. The onload function does everything you need to do with your XML document to be loaded.

Even if you want to populate the menu, you can do it on the onload. You can also display a family tree on the onload. The onload plays a key role in handling XML documents since it is then you have actual access to the XML document.

Preloaders can also be created for XML. Though they are not needed, it is good to know this information because there are some really huge files which you may have to load, and in those circumstances preloaders do come in handy. Making a preloader for XML is very similar to making a preloader for JPEG.

The only difference here is that instead of calling the getbytes from getbytes movie clip, you will be calling for this information from a XML instance. So preloaders for a movie can be created using a XML reference to the XML object. Whether it is a movie clip which is being played, or an XML instance, if the get bytes total and the get bytes loaded functions work, then it is sufficient.


Trackback(0)
Comments (0)add comment

Write comment

busy

 
< Prev   Next >
Sponsored Links
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape