Click a button and download a file in Flex is very simple but Adobe’s official example has a problem which made me spent like 20 mins to find a work around.
This won’t work:
var request:URLRequest = new URLRequest("index.xml"); var fileRef:FileReference = new FileReference(); fileRef.download(request);
But this will work:
var fileRef:FileReference = new FileReference(); function downloadFile():void { fileRef.download(new URLRequest("index.xml")); } downloadFile();

