Web design course - CHAPTER 10 USING FLASH TO DISPLAY XML
CHAPTER 10 USING FLASH TO DISPLAY XML 307 The doUpdate()function follows: function doUpdate():Void { if (booNew) { if (title_txt.text.length > 0) { var newDVD:XMLNode = oXML.createElement(”DVD”); newDVD.attributes.id = rootNode.childNodes.length + 1; var newDVDTitle:XMLNode = oXML.createElement(”title”); newDVDTitle.appendChild(oXML.createTextNode(title_txt.text)); newDVD.appendChild(newDVDTitle); if (format_txt.text.length > 0) { var newDVDFormat:XMLNode = oXML.createElement(”format”); newDVDFormat.appendChild(oXML.createTextNode(format_txt.text)); newDVD.appendChild(newDVDFormat); } if (genre_txt.text.length > 0) { var newDVDGenre:XMLNode = oXML.createElement(”genre”); newDVDGenre.appendChild(oXML.createTextNode(genre_txt.text)); newDVD.appendChild(newDVDGenre); } rootNode.appendChild(newDVD); loadList(null); clearTextInputs(); } } else { var selectedNodeIndex:Number = Number(selectedDVDNode.attributes.id)-1; if (title_txt.text.length > 0) { selectedDVDNode.childNodes[0].firstChild.nodeValue = title_txt.text; } if (format_txt.text.length > 0) { selectedDVDNode.childNodes[1].firstChild.nodeValue = format_txt.text; } if (genre_txt.text.length > 0) { selectedDVDNode.childNodes[2].firstChild.nodeValue = genre_txt.text; } loadList(selectedNodeIndex); } } You can divide the function into two areas the first section adds a new record, and the second edits an existing record. If you re adding a new record (booNew is true), the code tests whether the record has a title. The function won t proceed unless a title exists: if (title_txt.text.length > 0) {
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.