Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 401

Programming actionscript 3.0
Table of Contents

Advertisement

}
function completeHandler(event:Event):void
{
trace("uploaded");
}
The previous example creates a new URLVariables object that you pass to the remote server-
side script. In previous versions of ActionScript, you could pass variables to the server upload
script by passing values in the query string. ActionScript 3.0 allows you to pass variables to the
remote script using a URLRequest object, which allows you to pass data using either the
or
method; this, in turn, makes passing larger sets of data easier and cleaner. In order to
GET
specify whether the variables are passed using the
URLRequest.method
URLRequestMethod.POST
ActionScript 3.0 also lets you override the default
providing a second parameter to the
example (which replaced the default value
By default, Flash Player will not attempt to send a test upload, although you can override this
by passing a value of
the test upload is to check whether the actual file upload will be successful and that server
authentication, if required, will succeed.
A test upload occurs only on Windows-based Flash Players at this time.
Downloading files from a server
You can let users download files from a server using the
method, which takes two parameters:
the URLRequest object that contains the URL of the file to download. The second parameter
is optional—it lets you specify a default filename that appears in the download file dialog box.
If you omit the second parameter,
used.
The following code downloads a file named index.xml from the same directory as the SWF
document:
var request:URLRequest = new URLRequest("index.xml");
var fileRef:FileReference = new FileReference();
fileRef.download(request);
property to either
URLRequestMethod.GET
, respectively.
upload()
as the third parameter to the
true
request
defaultFileName
or
request method, you can set the
GET
POST
upload file field name by
Filedata
method, as demonstrated in the previous
with
Filedata
Custom1
upload()
FileReference.download()
and
defaultFileName
, the filename from the specified URL is
Working with file upload and download
or
).
method. The purpose of
. The first parameter is
POST
401

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents