简体   繁体   中英

Saving an XML file using AS3

Is there a way of actually saving this as an XML file itself to then be read into the flash file separately?

var book:XML = <book/>;
book.publisher = <publisher/>;
book.publisher.@name ="O'Reilly";

book.title = "Learning ActionScript 3.0";

book.appendChild(<subject/>);
book.subject.prependChild("Action Script");
book.insertChildAfter(book.subject, <authors/>);

book.authors.author.firstname = "Zevan";
book.authors.author.lastname = "Rosser";

var tempList:XMLList = book.authors.author.copy()
tempList[0].firstname = "Rich"
tempList[0].lastname = "Shupe"
book.authors.insertChildBefore(book.authors.author, tempList);

trace (book); 

There is a way, in fact there's already a question on stack overflow that had and adequate answer, you could check: Flash Actionscript 3 saving a XML file locally has a "Save As" window (How can I remove it?) . Any way, you could do it using AIR as flash has a library that will help you save files as a background process, you can find all the informations you need here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html

You can save this as an xml . and read in flash. store it locally and use shared object. check this link for reference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM