Is there anybody who knows anything about ActionScript 3.0? I need help with writing data to external XML file (load XML file, write data and further "save" it to the XML file.
Thanks a lot.
AS 3.0 - help me pls (out of topic)
-
- Site Administrator
- Сообщения: 2898
- Зарегистрирован: Fri Jul 28, 2006 10:58 am
- Location: Bialystok, Poland
Re: AS 3.0 - help me pls (out of topic)
http://www.republicofcode.com/tutorials/flash/xml/
When you're done with XML, you can save the contents of an object like any normal string to a regular file using method .toXMLString()
When you're done with XML, you can save the contents of an object like any normal string to a regular file using method .toXMLString()
- Morphid
- Site Administrator
- Сообщения: 86
- Зарегистрирован: Sat Dec 25, 2010 12:48 am
- Location: Czech Republic
- Контактная информация:
Re: AS 3.0 - help me pls (out of topic)
Thanks very much =))
- Morphid
- Site Administrator
- Сообщения: 86
- Зарегистрирован: Sat Dec 25, 2010 12:48 am
- Location: Czech Republic
- Контактная информация:
Re: AS 3.0 - help me pls (out of topic)
Ok, I've a code which reads data from external XML file. Now I want to add a new user to this xml and save it - when I close the Flash app and run it again, "the new user" will be there (in xml).
This is my XML:
and I added a new object to myXML (I don't know sure that this is the right class for adding an object to XML.. ), but when I see changes (trace(myXML) again..), these new elements are there..:
Code: Select all
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
var myXML = new XML();
var xmlReq:URLRequest = new URLRequest("../accounts.xml");
var xmlLoader:URLLoader = new URLLoader(xmlReq);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):void {
myXML = XML(xmlLoader.data);
trace(myXML);
}
Code: Select all
<accounts>
<user>
<name>Morphid</name>
<pass>dog8862</pass>
</user>
<user>
<name>Host</name>
<pass>cat94</pass>
</user>
</accounts>
Code: Select all
myXML.appendChild(<user><name>NewUser</name><pass>rat12</pass></user>);
trace(myXML);