Chapter 30. File Access

FEATURED CLASSES

  • flash.net.FileReference

  • flash.net.FileReferenceList

Flash Player can help your users connect their content with the rest of the world. With a good file API, you empower users to share their video, images, audio, and documents; to generate or receive receipts, maps, and shopping lists; and even to edit, post-process, or mash up songs or videos.

Abilities of the File API

The file management abilities of Flash Player have evolved over time, so different versions of Flash Player support different operations. Uploading files to the web via an HTTP post and saving files to the user's system from an HTTP request are supported in Flash Player 9 and up. Opening local files, accessing their content as a ByteArray, and saving content from Flash Player directly into a file on the user's system are supported in Flash Player 10 and up.

The AIR runtime includes even more detailed control over files, such as a stream interface to files, file-browsing components, and scripted access to files. I won't cover AIR runtime features here.

Any time you deal with files in Flash Player, the user is prompted to select a file or destination with a standard system dialog box. At no time can Flash Player open or save a file on its own accord. Nor can ActionScript code browse through the filesystem at will, even if the user is doing just that. Control is passed entirely away from ActionScript while the user confirms file actions.

Introducing FileReference

All file access in Flash ...

Get ActionScript 3.0 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.