FileReferenceList (flash.net.FileReferenceList)


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. While a call to FileReferenceList.browse() is executing, SWF file playback pauses on stand-alone and external players for Linux and Mac OS X 10.1 and earlier.

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

Modifiers

Property

Description

 

fileList:Array

An array of FileReference objects.

Properties inherited from class Object

constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property)


Event summary

Event

Description

onCancel = function(fileRefList:FileReferenceList) {}

Invoked when the user dismisses the file-browsing dialog box.

onSelect = function(fileRefList:FileReferenceList) {}

Invoked when the user selects one or more files to upload from the file-browsing dialog box.

Constructor summary

Signature

Description

FileReferenceList()

Creates a new FileReferenceList object.

Method summary

Modifiers

Signature

Description

 

addListener(listener:Object) : Void

Registers an object to receive notification when a FileReferenceList event listener is invoked.

 

browse([typelist:Array]) : Boolean

Displays a file-browsing dialog box in which the user can select one or more local files to upload.

 

removeListener(listener:Object) : Boolean

Removes an object from the list of objects that receive event notification messages.

Methods inherited from class Object

addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method)



Flash CS3