browse (FileReference.browse method)

public browse([typelist:Array]) : Boolean

Displays a file-browsing dialog box in which the user can select a local file to upload. The dialog box is native to the user's operating system. When you call this method and the user successfully selects a file, the properties of this FileReference object are populated with the properties of that file. Each subsequent time that FileReference.browse() is called, the FileReference object's properties are reset to the file selected by the user in the dialog box.

Only one browse() or download() session can be performed at a time (because only one dialog box can be displayed at a time).

You can pass an array of file types to determine which files the dialog box displays.

Availability: ActionScript 1.0; Flash Player 8

Parameters

typelist:Array [optional] - An array of file types used to filter the files displayed in the dialog box. If you omit this parameter, all files are displayed. If you include this parameter, the array must contain one or more elements enclosed in curly braces { }. You can use one of two formats for the array:

The two formats are not interchangeable in a single browse() call. You must use one or the other.

The list of extensions is used to filter the files in Windows, depending on the file selected by the user. It is not actually displayed in the dialog box. To display the file types for users, you must list the file types in the description string as well as in the extension list. The description string is displayed in the dialog box in Windows. (It is not used on the Macintosh.) On the Macintosh, if you supply a list of Macintosh file types, that list is used to filter the files. If you don't supply a list of Macintosh file types, the list of Windows extensions is used.

Returns

Boolean - Returns true if the parameters are valid and the file-browsing dialog box is displayed. Returns false if the dialog box is not displayed, if another browse session is already in progress, or if you use the typelist parameter but fail to provide a description or extension string in any element in the array.

Example

The following example displays a dialog box in which the user can select an image file to be uploaded.

import flash.net.FileReference;

var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
    trace("Opened " + file.name);
}

listener.onCancel = function(file:FileReference):Void {
    trace("User cancelled");
}

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

See also

onSelect (FileReferenceList.onSelect event listener), onCancel (FileReference.onCancel event listener), download (FileReference.download method), browse (FileReferenceList.browse method)


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/00001658.html