306 CHAPTER 10 USING FLASH TO DISPLAY (Web design online)
306 CHAPTER 10 USING FLASH TO DISPLAY XML The processXML()function is almost identical to the previous example. When it calls the loadList() function, it passes null, signifying that a DVD has not yet been selected. The loadList() function works a little differently from the previous example. This time it displays a string representation of the complete XMLNode object in the List component. The new and changed lines appear in bold in the following code block: function loadList(theNodeIndex:Number):Void { dvd_list.removeAll(); var dvdNode:XMLNode; for (var i:Number=0; i < rootNode.childNodes.length; i++) { dvdNode = rootNode.childNodes[i]; dvd_list.addItem(dvdNode.toString()); } if (theNodeIndex != null) { dvd_list.selectedIndex = theNodeIndex; } } The toString() method displays the content of each element within the List component. The new example includes onRelease handlers for each of the three buttons: Clear, Update, and Delete. The Clear button clears the selection: clear_btn.onRelease = function():Void { dvd_list.selectedIndex = undefined; selectedDVDNode = null; booNew = true; clearTextInputs(); } The function starts by removing the selection from the dvd_list component: dvd_list.selectedIndex = undefined; It then clears the selectedDVDNode variable by setting the value to null. The function sets the booNew variable to true and then calls the clearTextInputs() function to remove the text from the interface. The clearTextInputs() function follows: function clearTextInputs():Void { title_txt.text = ""; format_txt.text = ""; genre_txt.text = ""; } Clicking the Update button calls the doUpdate() function. This function either adds a new record to the XML tree or updates the currently selected element, depending on the value of the booNew variable.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.