Loading XML Data into Your Flash PresentationsIf you know how to load the XML data from an XML file into a flash presentation then it will be easy for you to create presentations that are dynamic in nature. It is possible to change the contents of the XML file alone with an interface that allows you to give a different presentation when needed. For this reason it is better to understand the logic behind this task. To build confidence in you, you have to start with a simple application that loads the XML data in to flash. Flash has a XML object for this purpose. Thursday, November 12th, 2020 Consider the XML file given below. The data from this file needs to be loaded in to your flash movie for displaying it. <?xml version="1.0"?> Save the above file as books.xml in your hard drive. The next step is to create a flash movie that can load the data from the XML file. Create a movie in flash and add text boxes to it using the text tool. From the properties panel for the text box, make sure you are selecting the dynamic text. In the first frame of your movie you have to add the following code in the actions panel. You can press F9 to bring the actions panel up to add the code. function loadXMLData(loaded) { In the above code we are writing the code to navigate to the <bookname> and the <author> tags in the XML file. Then we are assigning the text in that node to the text box in the movie. These tasks are written in a function called the loadXMLData. The code logic is to create an XML object and using the load method of that object to load the books.xml file. The ignoreWhite property of the XML object is used to ignore the white spaces within the XML file. This is needed since Flash may read the white spaces in the XML file if you are not using the MX version. In the function that navigates you should become familiar with the levels that are navigated. To extract value the .nodevalue is not used if you are using Flash MX and above. Note the change in the value of the index so that different values of the node are displayed. This simple example will give you an idea of how to load an external xml file and extract data from it using flash. If you are good programmer you can alter the loadXMLData function to display all the nodes successively when the user clicks a next button. For this purpose you have to create the next and previous button and add actions to them accordingly so that you are navigating the next and the previous nodes in the XML file.
|
Visit XML Training Material Guide Homepage
|
|||
|
||||
“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”
Copyright - © 2004 - 2020 - All Rights Reserved.