Save to XML file without user prompt dialog in action script 3?

How to save data to XML file without user prompt dialog in Action Script 3?

I am writing a simple application (with adobe flash) that runs on a client PC and saves user state data in an XML file in the same application directory. When I use FileReference, it shows a user dialog to save the file. Is there any class for saving only XML data directly to an XML file?

I think that writing only XML (text plane) data could not cause any security problems ?: -?

+3
source share
3 answers

- SharedObject. XML , , .

SharedObject , , 100 ( ) , , XML , , ByteArray.

:

var ba:ByteArray = new ByteArray;
ba.writeUTFBytes( myXML );
ba.compress();

:

try
{
    ba.uncompress();
}
catch ( e:Error )
{
    trace( "The ByteArray wasn't compressed!" );
}

// set our xml data
myXML = XML( ba );
+2

, . xml URLLoader, , dataFormat URLLoaderDataFormat.TEXT, .

,

private function loadConfigFromServer():void{
    var request:URLRequest = new URLRequest(serverConfigXmlLocation);
    configLoader = new URLLoader();

    configLoader.addEventListener(Event.COMPLETE, configLoadCompleteHandler);
            configLoader.addEventListener(IOErrorEvent.IO_ERROR, configLoadIOErrorEventHandler);
    configLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, configLoadSecurityErrorEventHandler);

    configLoader.dataFormat = URLLoaderDataFormat.TEXT;
    configLoader.load(request);

}


 private function configLoadCompleteHandler(event:Event):void{
     configLoader.removeEventListener(Event.COMPLETE, configLoadCompleteHandler);
     configLoader.removeEventListener(IOErrorEvent.IO_ERROR, configLoadIOErrorEventHandler);
     configLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,   configLoadSecurityErrorEventHandler);
     trace("config download complete");
     var fs:FileStream = new FileStream();
     try{
         fs.open(new File(localConfigXmlLocation), FileMode.WRITE);
         fs.writeMultiByte(configLoader.data, "unicode");
     }catch(error:IOError){
         trace("IOError saving config xml");
     }catch(error:SecurityError){
         trace("SecurityError saving config xml");
     }finally{
         fs.close();
         parseLocalConfig();
     }
}
+3

: XML AS3

With a shared object similar to the description of divillysausages, you can save an array, or XML data, or other variables for the shared object, so that you can get it later. You save this data only on the user's computer, so it cannot be used anywhere except locally on your machine. The short answer is, without a server-side interface for communication, you cannot save data to the actual XML file if it is a browser application or projector.

+1
source

All Articles