03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The File<strong>Reference</strong>List class provides a means to let users select one or more files for uploading.<br />

A File<strong>Reference</strong>List object represents a group of one or more local files on the user's disk as an<br />

array of File<strong>Reference</strong> objects. For detailed information <strong>and</strong> important considerations about<br />

File<strong>Reference</strong> objects <strong>and</strong> the File<strong>Reference</strong> class, which you use with File<strong>Reference</strong>List, see<br />

the File<strong>Reference</strong> class.<br />

To work with the File<strong>Reference</strong>List class:<br />

■ Instantiate the class: var myFileRef = new File<strong>Reference</strong>List();<br />

■ Call File<strong>Reference</strong>List.browse(), to display a dialog box in which the user can select<br />

one or more files to upload: myFileRef.browse();<br />

■ After browse() is successfully called, the fileList property of the File<strong>Reference</strong>List<br />

object is populated with an array of File<strong>Reference</strong> objects.<br />

■ Call File<strong>Reference</strong>.upload() on each element in the fileList array.<br />

The File<strong>Reference</strong>List class includes a browse() method <strong>and</strong> a fileList property for<br />

working with multiple files. While a call to File<strong>Reference</strong>List.browse() is executing,<br />

SWF file playback pauses on st<strong>and</strong>-alone <strong>and</strong> external players for Linux <strong>and</strong> Mac OS X 10.1<br />

<strong>and</strong> earlier.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 8<br />

Example<br />

The following example allows a user to select multiple files <strong>and</strong> then uploads each of them to<br />

a server.<br />

import flash.net.File<strong>Reference</strong>List;<br />

import flash.net.File<strong>Reference</strong>;<br />

var listener:Object = new Object();<br />

listener.onSelect = function(fileRefList:File<strong>Reference</strong>List) {<br />

trace("onSelect");<br />

var list:Array = fileRefList.fileList;<br />

var item:File<strong>Reference</strong>;<br />

for(var i:Number = 0; i < list.length; i++) {<br />

item = list[i];<br />

trace("name: " + item.name);<br />

trace(item.addListener(this));<br />

item.upload("http://www.yourdomain.com/");<br />

}<br />

}<br />

listener.onCancel = function():Void {<br />

trace("onCancel");<br />

}<br />

594 <strong>ActionScript</strong> classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!