Object | +-flash.net.FileReferenceList public class FileReferenceList extends Object The FileReferenceList class provides a means to let users select one or more files for uploading. A FileReferenceList object represents a group of one or more local files on the user's disk as an array of FileReference objects. For detailed information and important considerations about FileReference objects and the FileReference class, which you use with FileReferenceList, see the FileReference class. To work with the FileReferenceList class:
The FileReferenceList class includes a browse() method and a fileList property for working with multiple files. Availability: ActionScript 1.0; Flash Player 8 Example The following example allows a user to select multiple files and then uploads each of them to a server. import flash.net.FileReferenceList; import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(fileRefList:FileReferenceList) { trace("onSelect"); var list:Array = fileRefList.fileList; var item:FileReference; for(var i:Number = 0; i < list.length; i++) { item = list[i]; trace("name: " + item.name); trace(item.addListener(this)); item.upload("http://www.yourdomain.com/"); } } listener.onCancel = function():Void { trace("onCancel"); } listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); } listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); } listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); } listener.onHTTPError = function(file:FileReference, httpError:Number):Void { trace("onHTTPError: " + file.name + " httpError: " + httpError); } listener.onIOError = function(file:FileReference):Void { trace("onIOError: " + file.name); } listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: " + file.name + " errorString: " + errorString); } var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); See also FileReference (flash.net.FileReference) Property summary
Properties inherited from class Object
Event summary
Constructor summary
Method summary
Methods inherited from class Object
addListener (FileReferenceList.addListener method)public addListener(listener:Object) : Void Registers an object to receive notification when a FileReferenceList event listener is invoked. Availability: ActionScript 1.0; Flash Player 8 Parameters listener:Object - An object that listens for a callback notification from the FileReferenceList event listeners. Example The following example demonstrates the addListener() method. import flash.net.FileReferenceList; var listener:Object = new Object(); listener.onCancel = function(fileRefList:FileReferenceList) { trace("onCancel"); } listener.onSelect = function(fileRefList:FileReferenceList) { trace("onSelect: " + fileRefList.fileList.length); } var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); 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 Parameters 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:
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. 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 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); See also browse (FileReference.browse method), FileReference (flash.net.FileReference) fileList (FileReferenceList.fileList property)public fileList : Array An array of FileReference objects. When the FileReferenceList.browse() method has been called and the user has selected one or more files from the dialog box opened by browse(), this property is populated with an array of FileReference objects, each of which represents a file the user selected. You can then use this array to upload the files with FileReference.upload(). You must upload one file at a time. The fileList property is populated anew each time browse() is called on that FileReferenceList object. The properties of FileReference objects are described in the FileReference class documentation. Availability: ActionScript 1.0; Flash Player 8 Example The following example demonstrates the fileList property. import flash.net.FileReferenceList; import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(fileRefList:FileReferenceList) { trace("onSelect"); var list:Array = fileRefList.fileList; var item:FileReference; for(var i:Number = 0; i < list.length; i++) { item = list[i]; trace("name: " + item.name); } } var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); See also FileReference (flash.net.FileReference), upload (FileReference.upload method), browse (FileReferenceList.browse method) FileReferenceList constructorpublic FileReferenceList() Creates a new FileReferenceList object. This object contains nothing until you call browse() on it. When you call browse() on the FileReference object, the fileList property of the object is populated with an array of FileReference objects. Availability: ActionScript 1.0; Flash Player 8 Example The following example creates a new FileReferenceList object, iterates over each selected file, and outputs their names. import flash.net.FileReferenceList; var listener:Object = new Object(); listener.onSelect = function(fileRefList:FileReferenceList) { trace("onSelect"); var arr:Array = fileRefList.fileList; for(var i:Number = 0; i < arr.length; i++) { trace("name: " + arr[i].name); } } var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); See also FileReference (flash.net.FileReference), browse (FileReferenceList.browse method) onCancel (FileReferenceList.onCancel event listener)onCancel = function(fileRefList:FileReferenceList) {} Invoked when the user dismisses the file-browsing dialog box. (This dialog box is displayed when you call the FileReferenceList.browse(), FileReference.browse(), or FileReference.download() methods.) Availability: ActionScript 1.0; Flash Player 8 Parameters fileRefList:flash.net.FileReferenceList - The FileReferenceList object that initiated the operation. Example The following example demonstrates the onCancel listener. import flash.net.FileReferenceList; var listener:Object = new Object(); listener.onCancel = function(fileRefList:FileReferenceList) { trace("onCancel"); } var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); See also browse (FileReferenceList.browse method) onSelect (FileReferenceList.onSelect event listener)onSelect = function(fileRefList:FileReferenceList) {} Invoked when the user selects one or more files to upload from the file-browsing dialog box. (This dialog box is displayed when you call the FileReferenceList.browse(), FileReference.browse(), or FileReference.download() methods.) When the user selects a file and confirms the operation (for example, by clicking Save), the FileReferenceList object is populated with FileReference objects that represent the files selected by the user. Availability: ActionScript 1.0; Flash Player 8 Parameters fileRefList:flash.net.FileReferenceList - The FileReferenceList object that initiated the operation. Example The following example demonstrates the onSelect listener. import flash.net.FileReferenceList; import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(fileRefList:FileReferenceList) { trace("onSelect"); var list:Array = fileRefList.fileList; var item:FileReference; for(var i:Number = 0; i < list.length; i++) { item = list[i]; trace("name: " + item.name); trace(item.addListener(this)); item.upload("http://www.yourdomain.com/"); } } listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); } var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); See also browse (FileReferenceList.browse method) removeListener (FileReferenceList.removeListener method)public removeListener(listener:Object) : Boolean Removes an object from the list of objects that receive event notification messages. Availability: ActionScript 1.0; Flash Player 8 Parameters listener:Object - An object that listens for a callback notification from the FileReferenceList event listeners. Returns Boolean - Returns TRue if the object is removed. Otherwise, this method returns false. Example The following example demonstrates the removeListener method. import flash.net.FileReferenceList; var listener:Object = new Object(); listener.onCancel = function(fileRefList:FileReferenceList) { trace("onCancel"); trace(fileRefList.removeListener(this)); // true } listener.onSelect = function(fileRefList:FileReferenceList) { trace("onSelect: " + fileRefList.fileList.length); } var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); |