Delete XML information using AS3

Coldman

New Member
So currently I am able to save 1-9 AS3 variables depending on what the user wants, they are saved as text strings into an XML file however when the user saves again the old xml information remains in the file and the new information is added.However I want the new information to either write over the old information or set a function to clear/delete the information in the xml file before the new settings are saved.Here is my current save function:\[code\]var soundVAR;var conditionVAR;var soundtoXML:XML; var conditiontoXML:XML; var test = 1;var playingCounter = 0;var xml:XML = <saved> </saved>;//1.Button event listenerbtn_Save.addEventListener(MouseEvent.CLICK, saveXML);//2.The saveurl function which opens a URL.function saveXML(event:MouseEvent):void {var conditionsArray = new Array(play1Condition, play2Condition, play3Condition, play4Condition, play5Condition, play6Condition, play7Condition, play8Condition, play9Condition)for (var i=0; i < conditionsArray.length; i++){trace(conditionsArray)if(conditionsArray == true){ soundVAR = soundsName; conditionVAR = conditionsArray; playingCounter++; } else { trace('no sounds are playing');}while (xml.item.length() < playingCounter ){ var soundString:String = '<sound>' + soundVAR + '</sound>'; var conditionString:String = '<condition>' + conditionVAR + '</condition>'; soundtoXML = new XML(soundString); conditiontoXML = new XML(conditionString); var item:XML = <item /> item.@id = xml.item.length().toString(); xml.appendChild(item); var sound:XML = xml.item[xml.item.length() - 1]; var condition:XML = xml.item[xml.item.length() - 1]; sound.appendChild(soundtoXML); condition.appendChild(conditiontoXML);}}writeXML();trace(xml);}function writeXML(){var savedSounds:SharedObject = SharedObject.getLocal( 'savedSounds');savedSounds.data.soundsxml = xml; // your variablessavedSounds.flush(); // stores data into disk}\[/code\]Thanks in advanced.
 
Back
Top