Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > FileReferenceList (flash.net.FileReferenceList) > browse (FileReferenceList.browse method) | |||
public browse([typelist:Array]) : Boolean
Displays a file-browsing dialog box in which the user can select one or more local files to upload. The dialog box is native to the user's operating system. When you call this method and the user successfully selects files, the fileList property of this FileReferenceList object is populated with an array of FileReference objects, one for each file selected by the user. Each subsequent time that FileReferenceList.browse() is called, the FileReferenceList.fileList property is reset to the file or files selected by the user in the dialog box.
You can pass an array of file types to determine which files the dialog box displays.
Only one browse() or download() session can be performed at a time on a FileReferenceList object (because only one dialog box can be displayed at a time).
Availability: ActionScript 1.0; Flash Player 8
typelist:Array [optional] - An array of file types used to filter the files that are 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: "SWF files", 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;PNGf"}, {description: "SWF files", 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 type the user selects. 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 demonstrates the browse() method.
import flash.net.FileReferenceList; var allTypes:Array = new Array(); var imageTypes:Object = new Object(); imageTypes.description = "Images (*.JPG;*.JPEG;*.JPE;*.GIF;*.PNG;)"; imageTypes.extension = "*.jpg; *.jpeg; *.jpe; *.gif; *.png;"; allTypes.push(imageTypes); var textTypes:Object = new Object(); textTypes.description = "Text Files (*.TXT;*.RTF;)"; textTypes.extension = "*.txt; *.rtf"; allTypes.push(textTypes); var fileRef:FileReferenceList = new FileReferenceList(); fileRef.browse(allTypes);
browse (FileReference.browse method), FileReference (flash.net.FileReference)
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/00001682.html