Monthly Archives: February 2009

Adobe Air: File Storage Locations

Syntax difference Java ActionScript: http://java.sys-con.com/read/299251.htm

FileSystemAccess via Air Application

flash.filesystem.File

* applicationResourceDirectory is a reference to the application install path /Contents/Resources directory. For example, using applicationResourceDirectory to create the directory in this example will create the MyNewDirectory folder at /Users/rich/Applications/Chapter8File-API.app/Contents/Resources/MyNewDirectory on Mac or C:\Documents and Settings\rich\Local Settings\Application Data\Chapter8-FileAPI\MyNewDirectory on Windows.

* applicationStorageDirectory is a reference to the default storage location for the application. For example, on a Mac it will create the directory at /Users/rich/Library/Preferences/Chapter8-FileAPI/Local Store/MyNewDirectory, while on Windows it will create the folder at C:\Documents and Settings\rich\Application Data\Chapter8-FileAPI\Local Store\MyNewDirectory.

* desktopDirectory is a reference to the users desktop directory. For example, on a Mac it will create the directory at /Users/rich/Desktop/MyNewDirectory, while on Windows it will create the directory at C:\Documents and Settings\rich\Desktop\MyNewDirectory.

* documentsDirectory is a reference to the users documents directory. For example, on a Mac it will create the directory at /Users/rich/Documents/MyNewDirectory, while on Windows it will create the directory at C:\Documents and Settings\rich\My Documents\MyNewDirectory.

* userDirectory is a reference to the user directory. For example, on a Mac it will create the directory at /Users/rich/MyNewDirectory, while on Windows it will create the directory at C:\Documents and Settings\rich\MyNewDirectory.

Air Storage Options

Local Shared Objects. You can serialize memory resident data structures. Great! However, it runs in synchronous mode.

Encrypted Local Store. Used to store sensitive data. The price is the slow write speeds.  Also runs in synchronous mode. All data is serialized using ByteArray.

File System. Obviously important for management of documents. Can run in sync and async mode. The File and FileStream objects work together to point to a file and read/write data. The File object helps remove you from the pain of dealing with Mac vs. Windows environments with properties like File.userDirectory, File.documents.Directory, File.desktopDirectory, etc. It also has methods for opening Open and Save dialog boxes native to the environment as well as copying/moving/deletion methods.

Embedded SQLite Database.  Nice thing about them is that they are self-contained in a single file and require no external software installation to begin using them (support is built into the AIR runtime). Even supports transactions. And the database supports large amounts of data: SQLite has a theoretical limit of over 2TB. Supports ANSI-SQL 92.

ActionScript 3.0: Code Snippets

Datatypes

String Text
Boolean  0 == false, everything other than 0 is true;
Number  Everything
Int  Ganzzahlen
Uint  Positive integers
Array  Array
Error  ErrorType
Date  Specific point of time

Classes

Math  MathTools
RegExp  Tools for searching and Replacing Text
Function
Object  Basic Object

Event Listener Syntax

addEventListener( type, listener, use Capture (boolean), priority(uint), UseWeak Reference)

Overriding Functions in ActionScript:

public class A {

function someFunction(){

}

}

public class B extends A {

override function someFunction(){

}

//call A function

super.someFunction();

}

Using Intervals

flash.utils.setInterval

flash.utils.clearInterval

instanceVariable = setIntervall(function, intervall);

set Intervall calls a function with a timed intervall (in milliseconds)

clearIntervall(instanceVariable) //removes the timer