I don't get that error.

 

Here is what I think is the fix which is to have the variables declared
outside the function. My guess is that due to the file download not being
complete within the doIt function, the variables are destroyed when the
function completes along with it the download.

 

So declaring the functions at the component level resolves that issue, that
makes sense to me but it a logical guess so may not be correct.

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute">

      <mx:Script>

            <![CDATA[

                import flash.net.FileReference;

                  

                  private var request:URLRequest;

                  private var fileRef:FileReference;

                

                  private function doIt():void {

                        request = new
URLRequest("http://learncf.com/img/btnTutorial.png";);

                        fileRef = new FileReference();

                        fileRef.download(request);

                  }

                  

            ]]>

      </mx:Script>

      

      <mx:Button x="10" y="10" label="Button" click="doIt();" width="166"
height="126"/>

      

</mx:Application>

 

 

 

Regards

Dale Fraser

 <http://learncf.com> http://learncf.com

 

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Sherif Abdou
Sent: Tuesday, 4 March 2008 4:49 PM
To: [email protected]
Subject: Re: [flexcoders] File Download Not Working

 

There is an error which is

Error: Error #2037: Functions called in incorrect sequence, or earlier call
was unsuccessful.

I think maybe security box or something

----- Original Message ----
From: Dale Fraser <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, March 3, 2008 11:32:36 PM
Subject: [flexcoders] File Download Not Working

Why doesn?t this work

 

The app runs, get a download prompt, click save. No error. But no file. And
the completeHandler never fires, never see the trace.

 

Must be missing something obvious.

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe. com/2006/ mxml"
layout="absolute">

      <mx:Script>

            <![CDATA[

                import flash.net <http://flash.net.fi/> .FileRefer ence;

                

                  private function doIt():void {

                        var request:URLRequest = new
URLRequest("http://learncf. com/img/btnTutor ial.png");

                        var fileRef:FileReferen ce = new FileReference( );

                        fileRef.addEventLis tener(Event. COMPLETE,
completeHandler) ;

                        fileRef.download( request);

                  }

                  

                  private function completeHandler( ):void {

                        trace('complete');

                  }

            ]]>

      </mx:Script>

      

      <mx:Button x="10" y="10" label="Button" click="doIt();" width="166"
height="126"/>

      

</mx:Application>

 

Regards

Dale Fraser

http://learncf. <http://learncf.com/>  com

 

 

 

  _____  

Never miss a thing. Make Yahoo
<http://us.rd.yahoo.com/evt=51438/*http:/www.yahoo.com/r/hs>  your homepage.


 

Reply via email to