Writing files

AIR provides a file system API that can be used to write files of any type to the device.

Let us see how to write a text file containing simple preferences data that might, for example, be used by a game.

Getting ready

An FLA has been provided as a starting point for this recipe.

From the book's accompanying support files, open chapter13\recipe4\recipe.fla into Flash Professional.

Sitting on the stage is a dynamic text field named output. We will write some preferences data to the device and use the text field to indicate when the data has been written.

How to do it...

The flash.filesystem package contains classes that provide file system access. Let us make use of some of those classes to write to the device.

  1. Create a document class and ...

Get Flash iOS Apps Cookbook 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.