ActionScript 3.0 Language and Components Reference | All Packages | All Classes | Language Elements | Index | Appendixes | Conventions | Frames No Frames |
FileFilter

Package | flash.net
Class | public final class FileFilter
Inheritance | FileFilter Object

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

The FileFilter class is used to indicate what files on the user's system are shown in the file-browsing dialog box that is displayed when `FileReference.browse()` or `FileReferenceList.browse()` is called. FileFilter instances are passed to a `browse()` function. If you use a FileFilter instance, extensions and file types that aren't specified in the FileFilter instance are filtered out; that is, they are not available to the user to select for uploading. If no FileFilter object is passed to `browse()`, all files are shown in the dialog box.

You can use FileFilter instances in one of two ways:

- A description with Windows file extensions only
- A description with Windows file extensions and Macintosh file types

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

You can pass one or more FileFilter instances to `FileReference.browse()` or `FileReferenceList.browse()`. The following examples show different ways to create and pass FileFilter instances to a `browse()` call (for Windows only). The first example creates FileFilter instances outside of the `browse()` call:

     var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.gif;*.png");
     var docFilter:FileFilter = new FileFilter("Documents", "*.pdf;*.doc;*.txt");
     var myFileReference:FileReference = new FileReference();
     myFileReference.browse([imagesFilter, docFilter]);

The second example creates FileFilter instances within the `browse()` call:

     myFileReference.browse( [ new FileFilter("Images", "*.jpg;*.gif;*.png"), new FileFilter("Flash Movies", "*.swf") ] );

The list of extensions in the `FileFilter.extension` property 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 not, the list of Windows extensions is used.

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | description : String The description string for the filter. | FileFilter
|  | extension : String A list of file extensions. | FileFilter
|  | macType : String A list of Macintosh file types. | FileFilter
|  | prototype : Object [static] A reference to the prototype object of a class or function object. | Object

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | FileFilter(description:String, extension:String, macType:String = null) Creates a new FileFilter instance. | FileFilter
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

description | property

`description:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

The description string for the filter. The description is visible to the user in the dialog box that opens when `FileReference.browse()` or `FileReferenceList.browse()` is called. The description string contains a string, such as `"Images (*.gif, *.jpg, *.png)"`, that can help instruct the user on what file types can be uploaded or downloaded. Note that the actual file types that are supported by this FileReference object are stored in the `extension` property.

Implementation
`public function get description():String`
`public function set description(value:String):void`

extension | property |

`extension:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

A list of file extensions. This list indicates the types of files that you want to show in the file-browsing dialog box. (The list is not visible to the user; the user sees only the value of the `description` property.) The `extension` property contains a semicolon-delimited list of Windows file extensions, with a wildcard (*) preceding each extension, as shown in the following string: `"*.jpg;*.gif;*.png"`.

Implementation
`public function get extension():String`
`public function set extension(value:String):void`

macType | property |

`macType:String` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

A list of Macintosh file types. This list indicates the types of files that you want to show in the file-browsing dialog box. (This list itself is not visible to the user; the user sees only the value of the `description` property.) The `macType` property contains a semicolon-delimited list of Macintosh file types, as shown in the following string: `"JPEG;jp2_;GIFF"`.

Implementation
`public function get macType():String`
`public function set macType(value:String):void`
Constructor Detail

FileFilter | () | Constructor

`public function FileFilter(description:String, extension:String, macType:String = null)`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9

Creates a new FileFilter instance.

Parameters

| `description:String` — The description string that is visible to users when they select files for uploading.
| `extension:String` — A list of file extensions that indicate which Windows file formats are visible to users when they select files for uploading.
| `macType:String` (default = `null`)`` — A list of Macintosh file types that indicate which file types are visible to users when they select files for uploading. If no value is passed, this parameter is set to `null`.

Submit Feedback on LiveDocs
© 2004-2008 Adobe Systems Incorporated. All rights reserved.
Tue May 20 2008, 04:02 AM -07:00