I want to Export a table from my database to an excel file on the server and then download it. The following is the code that I developed for this purpose:
 import flash.net.FileReference;
 import flash.net.URLRequest;
 public function sqlDownloadExcel():void {
      var http:HTTPService = new HTTPService;
      var parm:Object = new Object;
      var sql:String;
      sql = "insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=C:\\inetpub\wwwroot\\myApp\\App_Data\\myExport.xls;', 'SELECT * FROM [Sheet1$]')  SELECT * FROM myTable";
      parm.sql = sql;
      parm.db = "myDatabase"; 
      http.url = "http://mywebsite.com/SQLconnector/sqlconnector.asp?irand="+Math.random();
      http.showBusyCursor = true;
      http.request = sql;
      http.addEventListener(ResultEvent.RESULT, function(e:ResultEvent):void {sqlDownloadExcelResult(e);});
      http.addEventListener(FaultEvent.FAULT, mssqlFault);
      http.method = "POST"; 
      sqlToken = http.send(parm);
 }
 public function sqlDownloadExcelResult(event:ResultEvent):void{
      var request:URLRequest = new URLRequest("http://mywebsite/myApp/App_Data/myExport.xls");
      var fileRef:FileReference = new FileReference();
      fileRef.download(request);                
 }
The code creates the Excel file on the server correctly, but running the fileRef.download(request) functions causes the following error:
Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
Any advice would be much appreciated. Thank you