94 | Chapter 4: AIR Mini-Cookbook
</head>
<body onload="doLoad( )">
<input id="btnBrowse" type="button" value="Browse" />
</body>
</html>
File Pickers
Browse for a File
Problem
An application needs to prompt the user to select a file to
open from the local system using a native dialog.
Solution
TheFileclass allows an application to prompt the user to
select one or more files of a specific type from the local
system.
Discussion
TheFileclass provides numerous browse methods that
present the native dialog for the specified operation. In the
case of browsing for a single file to open, the appropriate
method is File.browseForOpen( ). This method takes a
required string argument for the title of the dialog box, and
an optional Array ofFileFilter objects.
FileFilterobjects allow an application to filter the viewable
files in the native dialog box. This argument is null by
default, which allows the user to select any file to which they
would normally have access (i.e., not hidden files). An appli-
cation can provide as many filters as necessary, by placing
multipleFileFilterobjects in an Array and passing that
Array as the second argument toFile.browseForOpen( );.