Search code examples
actionscript-3apache-flexflex3filereference

Getting an error in FileReference.save method


I am currently working in Flex 3.0 I am getting an error(screen shot is given below). I am using Flash Player Version 10.0

Currently I am calling the HTTPService and in the resultHandler of that HTTPService i am getting an error in method filereference.save() . because this method is called only when the MouseEvent or Keyboard event is occured.

Is there any solution to overcome this situation or in other words calling the filereference.save method in ResultHandler.

enter image description here


Solution

  • You cannot. You need a click button of the user to get it done. Dispatching a MouseEvent is useless. Romi approach coud help you. But you need for security reasons to made it for a button click.

    What I did.. was in the result retrive the file location and open it like an html page. Then you can download it. I see no other solution than forcing the user to click a button like Romi said.

    var u:URLRequest = new URLRequest(event.result); 
    navigateToURL(u, "_blank");