Oftentimes, we may want to read certain files from the application storage or from some other location on our Android device. In the following example, we will perform this action upon a simple text file, but this can also be used to read in all sorts of files from image data to encoded MP3
audio bytes.
Employ a variety of classes within the flash.filesystem
package to open local file data within an application:
1. First, we will need to import the following classes:
import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.Event; import flash.filesystem.File; import flash.filesystem.FileMode; import flash.filesystem.FileStream; import flash.text.TextField; import flash.text.TextFormat;
2. We will now go about defining a set of constants and variables to be used throughout the application. Initialize a
String
constant to retain the file path, which will be used within the...