Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > FileReference (flash.net.FileReference) > 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
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:
[{description: "string describing the first set of file types", extension: "semicolon-delimited list of file extensions"}][{description: "Images", extension: "*.jpg;*.gif;*.png"}, {description: "Flash Movies", extension: "*.swf"}, {description: "Documents", extension: "*.doc;*.pdf"}][{description: "string describing the first set of file types", extension: "semicolon-delimited list of Windows file extensions", macType: "semicolon-delimited list of Macintosh file types"}][{description: "Image files", extension: "*.jpg;*.gif;*.png", macType: "JPEG;jp2_;GIFF"}, {description: "Flash Movies", extension: "*.swf", macType: "SWFL"}]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.
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.
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();
onSelect (FileReferenceList.onSelect event listener), onCancel (FileReference.onCancel event listener), download (FileReference.download method), browse (FileReferenceList.browse method)
Version 8
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/8/main/00002206.html
Comments
newyorkr said on Jan 3, 2006 at 6:16 AM : danpamfil said on Apr 13, 2006 at 6:13 AM : r_noise said on Jun 23, 2006 at 8:33 AM : webweber said on Oct 19, 2006 at 10:52 PM : webweber said on Oct 30, 2006 at 12:03 AM : No screen name said on Dec 18, 2006 at 1:50 PM : victor.lopez said on Jun 6, 2007 at 12:53 PM :