Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 414

Programming actionscript 3.0
Table of Contents

Advertisement

pb.label = "DOWNLOAD CANCELLED";
btn.enabled = false;
}
First, the code stops the file transfer immediately, preventing any further data from
downloading. Next, the progress bar's label property is updated to notify the user that the
download has been successfully cancelled. Finally, the Cancel button is disabled, which
prevents the user from clicking the button again until they attempt to download the file again.
Uploading files to a remote server
The file upload process is very similar to the file download process. The FileUpload class
declares the same four variables, as shown in the following code:
private const UPLOAD_URL:String = "http://www.yourdomain.com/
your_upload_script.cfm";
private var fr:FileReference;
private var pb:ProgressBar;
private var btn:Button;
Unlike the
FileDownload.DOWNLOAD_URL
URL to the server-side script that will upload the file from the user's computer. The
remaining three variables behave the same as their counterparts in the FileDownload class.
Initializing the FileUpload component
The FileUpload component contains an
application. This method takes two parameters,
ProgressBar and Button component instance on the Stage. Next, the
initializes the FileReference object defined earlier in the FileUpload class. Finally, the method
assigns four event listeners to the FileReference object. The code for the
follows:
public function init(pb:ProgressBar, btn:Button):void
{
this.pb = pb;
this.btn = btn;
fr = new FileReference();
fr.addEventListener(Event.SELECT, selectHandler);
fr.addEventListener(Event.OPEN, openHandler);
fr.addEventListener(ProgressEvent.PROGRESS, progressHandler);
fr.addEventListener(Event.COMPLETE, completeHandler);
}
414
Networking and Communication
variable, the
UPLOAD_URL
method, which gets called from the main
init()
and
, which are references to a
pb
btn
variable contains the
method
init()
method is as
init()

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents