onSelect (FileReference.onSelect event listener)

onSelect = function(fileRef:FileReference) {}

Invoked when the user selects a file to upload or download from the file-browsing dialog box. (This dialog box is displayed when you call FileReference.browse(), FileReferenceList.browse(), or FileReference.download().) When the user selects a file and confirms the operation (for example, by clicking OK), the properties of the FileReference object are populated.

The onSelect listener works slightly differently depending on what method invokes it. When onSelect is invoked after a browse() call, Flash Player can read all of the FileReference object's properties, because the file selected by the user is on the local file system. When onSelect is invoked after a download() call, Flash Player can read only the name property, because the file hasn't yet been downloaded to the local file system at the moment onSelect is invoked. When the file has been downloaded and onComplete invoked, then Flash Player can read all other properties of the FileReference object.

Availability: ActionScript 1.0; Flash Player 8

Parameters

fileRef:FileReference - The FileReference object that initiated the operation.

Example

The following example traces a message within the onSelect event listener.

import flash.net.FileReference;

var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
    trace("onSelect: " + file.name);
    if(!file.upload("http://www.yourdomain.com/yourUploadHandlerScript.cfm")) {
        trace("Upload dialog failed to open.");
    }
}

var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
fileRef.browse();

Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001673.html