The issue here is quite likely the garbage collector doing its job...

You FileRefence object is referenced only in a local variable in
the deskClickHandler method. After the method returns, since there's no
other reference to it, it's eligible for collection. So it might stick
around or not. In your case, it seems it doesn't. Try storing the fileref in
an instance variable instead. It should fix it, I think.

Cheers
Juan Pablo Califano

2010/8/9 Matt S. <mattsp...@gmail.com>

> I'm trying to use fileReference to allow users to download images, but
> it keeps failing, without errors, and without even seeming to start
> the download. What makes it weird is that it does open the finder
> window and prompts me to save the select a download location etc, but
> then when I click save...nothing. No errors, no files, just nothing.
> Here is the code I'm currently using (with puppy photo substituted for
> actual content). This is failing both locally and when uploaded to the
> server. Any suggestions much appreciated, I've been googling but
> havent found a solution.
>
> tia,
>
> Matt
>
>
> //CODE
>
>
> private function deskClickHandler(e:MouseEvent):void{
>
>        var downloadURL:URLRequest;
>       var fileName:String = "SomeFile.pdf";
>        var file:FileReference;
>
>        downloadURL = new URLRequest();
>        downloadURL.url =
> "http://mystuffspace.com/graphic/adorable-puppies.jpg";;
>        file = new FileReference();
>        file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
>        file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
>        file.addEventListener(Event.COMPLETE, completeHandler);
>        file.download(downloadURL, fileName);
> }
>
> private function progressHandler(event:ProgressEvent):void {
>    var file:FileReference = FileReference(event.target);
>    trace("progressHandler: name=" + file.name + " bytesLoaded=" +
> event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
> }
>
> private function ioErrorHandler(event:IOErrorEvent):void {
>    trace("ioErrorHandler: " + event);
> }
>
> private function completeHandler(event:Event):void {
>    trace("completeHandler: " + event);
> }
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to