here my codes :
package com.func
{
public class Downloader
{
import flash.events.*;
import flash.filesystem.*;
import flash.net.FileReference;
import flash.net.URLStream;
import flash.utils.ByteArray;
import flash.net.URLRequest;
import mx.controls.Alert;
private var req:URLRequest = new URLRequest();
private var us:URLStream = new URLStream();
private var fs:FileStream = new FileStream();
public function Downloader()
{
}
public function download():void{
var file:File = File.applicationDirectory.resolvePath("quotes.csv");
req.url = "http://www.domain.com/data.csv";
us.addEventListener(ProgressEvent.PROGRESS, writeFile);
us.addEventListener(Event.COMPLETE, loaded);
fs.openAsync(file, FileMode.WRITE);
us.load(req);
}
public function writeFile(event:Event):void{
var data:ByteArray = new ByteArray();
us.readBytes(data, 0, us.bytesAvailable);
fs.writeBytes(data, 0, data.length);
}
public function loaded(event:Event):void{
var data:ByteArray = new ByteArray();
us.readBytes(data, 0, us.bytesAvailable);
fs.writeBytes(data, 0, data.length);
fs.close();
}
}
}
when I execute, and start the function there's always become error. Error message is like this : SecurityError: fileWriteResource at runtime::SecurityManager$/checkPrivilegeForCaller() at flash.filesystem::FileStream/openAsync()
So, anyone can help me ....