2013-07-03 71 views
0

我正在使用adobe flash cs6和as3。我有一个XML文件,我需要添加一个节点。当我尝试它的工作正常。但当实例关闭时,我用记事本打开XML文件,它实际上并没有保存到原始文件。我的XML文件本地存储在Flash项目的同一文件夹中。我需要一个解决方案,而不使用PHP等其他语言。请帮助AS3 xml帮助:更新和保存xml文件

var myXML:XML; var myLoader:URLLoader = new URLLoader(); myLoader.load(new URLRequest("family.xml")); myLoader.addEventListener(Event.COMPLETE,xmlDownloaded) function xmlDownloaded(event:Event):void { 
    var xmlData:XML = new XML(event.target.data); var attention:XML 
    var surname:String= [email protected]; 
    var location:String= [email protected]; 

    // get the first granddaughter's age of the first daughter 
    var grandchild_age:Number= Number([email protected]); //trace(xmlData.DAUGHTER); [email protected]="85";  [email protected]="85";  trace(xmlData.*); 
} 

回答

0

我想你需要在编辑它后保存该xml文件。你应该尝试做这样的事情,你做的所有更改的XML后:

var file:FileReference = new FileReference; 
file.save(xmlData , "family.xml"); 

或像这样:

FileReference().save(xmlData , "family.xml"); 
+0

它清除已经包含数据? – wizard

+0

它不自动保存文档 – wizard

+0

它不应该清除任何数据,但我只记得它会显示“另存为”对话框。如果对你有问题,你可以看看这里的答案: http://stackoverflow.com/questions/16138905/autosaving-to-xml-using-filereference-save-without-having-a-save-as-dialog -来 – jfgi