A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileFilter.html below:

Adobe ActionScript® 3 (AS3 ) API Reference

Language Version:  ActionScript 3.0 Runtime Versions:  AIR 1.0, 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 the

FileReference.browse()

method, the

FileReferenceList.browse()

method is called or a browse method of a File, FileReference, or FileReferenceList object is called. FileFilter instances are passed as a value for the optional

typeFilter

parameter to the method. 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 for selection. If no FileFilter object is passed to the method, all files are shown in the dialog box.

You can use FileFilter instances in one of two ways:

The two formats are not interchangeable within a single call to the browse method. You must use one or the other.

You can pass one or more FileFilter instances to the browse method, as shown in the following:

 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]);
 

Or in an AIR application:

 var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.gif;*.png");
 var docFilter:FileFilter = new FileFilter("Documents", "*.pdf;*.doc;*.txt");
 var myFile:File = new File();
 myFile.browseForOpen("Open", [imagesFilter, docFilter]);
 

The list of extensions in the FileFilter.extension property is used to filter the files shown in the file browsing dialog. The list 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 and Linux. (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 file extensions is used.


description:String Language Version:  ActionScript 3.0 Runtime Versions:  AIR 1.0, 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:String Language Version:  ActionScript 3.0 Runtime Versions:  AIR 1.0, 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 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:String Language Version:  ActionScript 3.0 Runtime Versions:  AIR 1.0, 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
public function FileFilter(description:String, extension:String, macType:String = null) Language Version:  ActionScript 3.0 Runtime Versions:  AIR 1.0, 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 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.
Example  ( How to use this example )

The following example uploads an image from your local file system to the root display object (in this case, the stage). Example provided by

Andre Venancio

.

var buttonShape:Shape = new Shape();
buttonShape.graphics.beginFill(0x336699);
buttonShape.graphics.drawCircle(50, 50, 25);
var button = new SimpleButton(buttonShape, buttonShape, buttonShape, buttonShape);
addChild(button);

var fileRef:FileReference= new FileReference();
button.addEventListener(MouseEvent.CLICK, onButtonClick);

function onButtonClick(e:MouseEvent):void {
fileRef.browse([new FileFilter("Images", "*.jpg;*.gif;*.png")]);
fileRef.addEventListener(Event.SELECT, onFileSelected);
}

function onFileSelected(e:Event):void {
fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
fileRef.load();
}

function onFileLoaded(e:Event):void {
var loader:Loader = new Loader();
loader.loadBytes(e.target.data);
addChild(loader);
}


© 2015 Adobe Systems Incorporated. All rights reserved.
Thu Dec 6 2018, 01:12 PM -08:00

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4