Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 412

Programming actionscript 3.0
Table of Contents

Advertisement

Beginning the file download
When the user clicks the Download Button component instance on the Stage, the
method is to initiate the file download process. The following excerpt
startDownload()
shows the
startDownload()
/**
* Begin downloading the file specified in the DOWNLOAD_URL constant.
*/
public function startDownload():void
{
var request:URLRequest = new URLRequest();
request.url = DOWNLOAD_URL;
fr.download(request);
}
First, the
startDownload()
URL to the value specified by the
FileReference.download()
passed as a parameter. This causes the operating system to display a dialog box on the user's
computer prompting them to select a location to save the requested document. Once the user
selects a location, the
method is invoked.
The
openHandler()
property, and enables the Cancel button, which allows the user to immediately stop the
download in progress. The
/**
* When the OPEN event has dispatched, change the progress bar's label
* and enable the "Cancel" button, which allows the user to abort the
* download operation.
*/
private function openHandler(event:Event):void
{
pb.label = "DOWNLOADING %3%%";
btn.enabled = true;
}
412
Networking and Communication
method:
method creates a new URLRequest object, and sets the target
DOWNLOAD_URL
method is called, and the newly created URLRequest object is
event (
open
Event.OPEN
method sets the text format for the ProgressBar component's
openHandler()
variable. Next, the
) is dispatched and the
method is as follows:
openHandler()
label

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents