Sergio
Sergio

Reputation: 628

Air 2 desktop / Server / AS3: read/write XML

I have an Adobe Air 2 app developed for single desktop usage. It reads/write XML files stored in My Documents. (Win)

I must adapt this Air 2 app to read/write data through a server from several computers of a network.

I'd like to find a working sample in order to modify the single desktop app and make it server based, with XML read/write capabilities.

Any help will be highly regarded.

Upvotes: 1

Views: 666

Answers (2)

mika
mika

Reputation: 1451

There are many ways of doing it, thousands... But in any way you chose, you'll need a backend script running on the server to handle incoming requests (POST or GET). Or eventually a socket server but that is more complicated if you're not sure what you're doing.

Look into form submission scripts with PHP, maybe start by reading this post: http://johannesluderschmidt.de/save-xml-and-text-files-from-flash-to-your-hd-with-as3-and-php/127/

Good luck!

Upvotes: 1

chakroun yesser
chakroun yesser

Reputation: 1487

    import flash.text.*;


var xmlData:XML = new XML();

var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.load(new URLRequest("exemple.xml"));
    xmlLoader.addEventListener(Event.COMPLETE, function(e:Event){
        xmlData=new XML(e.target.data);

        var myText:TextField = new TextField();
        myText.text=xmlData;
        addChild(myText);
        myText.type = TextFieldType.INPUT;
    });


btn_save.buttonMode = true;
btn_save.addEventListener(MouseEvent.CLICK, saveXML)

function saveXML(event:MouseEvent):void {
    var ba:ByteArray = new ByteArray();
    ba.writeUTFBytes(xmlData);
    var file:FileReference = new FileReference();
    file.save(ba, "exemple.xml");
}

Upvotes: 0

Related Questions