Hi now I have found how to give a relative path in URLRequest paramate and download that file. I found it from this particular stack overflow post . Thanks to Christian Nunciato and heri0n.
so now if If give my machine's relative path, C:/sample/DefectList.xls
it works.
Now I have to access an xls file kept in the server machine or any other machine,say my team mate's machine. The ip address is 172.17.196.124
and the location is C:/sample/test.xls
.
I tried
var request:URLRequest = new URLRequest"file://172.17.196.124/c:/sample/test.xls");
But it throws the Error#2032.
How to mention a remote location as a relative path?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="loadFile()">
<mx:Script>
<![CDATA[
private var loadedFile:ByteArray;
private function loadFile():void
{
//var request:URLRequest = new URLRequest("C:/sample/DefectList.xls");
var request:URLRequest = new URLRequest("file://172.17.196.124/c:/sample/test.xls");
var urlLoader:URLLoader = new URLLoader(request);
urlLoader.addEventListener(Event.COMPLETE, onURLLoaderComplete);
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.load(request);
}
private function onURLLoaderComplete(event:Event):void
{
loadedFile = event.target.data;
}
private function saveLoadedFile():void
{
var file:FileReference = new FileReference();
file.save(loadedFile);
}
]]>
</mx:Script>
<mx:Button label="Save File" horizontalCenter="0" verticalCenter="0" click="saveLoadedFile()" />
</mx:Application>