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
- Posty: 2898
- Rejestracja: pt lip 28, 2006 10:58 am
- Lokalizacja: 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
- Posty: 86
- Rejestracja: sob gru 25, 2010 12:48 am
- Lokalizacja: Czech Republic
- Kontakt:
Re: AS 3.0 - help me pls (out of topic)
Thanks very much =))
- Morphid
- Site Administrator
- Posty: 86
- Rejestracja: sob gru 25, 2010 12:48 am
- Lokalizacja: Czech Republic
- Kontakt:
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..:
Kod: Zaznacz cały
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);
}
Kod: Zaznacz cały
<accounts>
<user>
<name>Morphid</name>
<pass>dog8862</pass>
</user>
<user>
<name>Host</name>
<pass>cat94</pass>
</user>
</accounts>
Kod: Zaznacz cały
myXML.appendChild(<user><name>NewUser</name><pass>rat12</pass></user>);
trace(myXML);