Posts tagged "ActionScript"

Beta ActionScript 3.0 Reference documentation available for Flash Player 10.3 Beta

The prerelease ActionScript 3.0 Reference for Flash Player 10.3 (“Wasabi”) Beta is now available. You can find this documentation here.

The Wasabi project represents the convergence of Flash Player and AIR streams into a single quarterly update.

Highlights include the following new features and classes:

Acoustic echo cancellation (Flash Player)
Exclude unwanted echo artifacts from microphone audio captures.

Media measurement (Flash Player)
Implement media usage analysis on the Flash Player platform rather than as a player plugin. Collect stats independently of the video player being used.

HTMLLoader updates (AIR)
The HTMLLoader class now dispatches locationChanging and locationChange events with a LocationChangeEvent object as the payload.

Important! To see the beta classes, remember to set your Runtimes filter to include Flash Player 10.3 and earlier.

Please use the Comments area at the bottom of each page to give us feedback on this beta documentation.

Filesystem access in an AIR for TV app

If you are writing or planning to write apps for AIR 2.5 for TV, you’ve probably already been looking at the documents and tutorials on http://www.adobe.com/devnet/devices/flash_platform_tv.html.

More docs are in the works, but in the meantime I thought I’d use this blog to present some of that content.

AIR for TV apps can access the device’s filesystem, but on a “living room” device it is critically important that an app cannot access the device’s system files or the files of other applications installed on the device. Users of TVs and associated devices do not expect or tolerate any device failures — they are watching TV, after all.

Therefore, an AIR for TV application has a limited view of the device’s filesystem. Using ActionScript 3.0, your app can access only the following directories (and their subdirectories). But realize that these names are not the actual directory names on the device. This extra layer protects AIR for TV  applications from maliciously or inadvertently accessing local files that do not belong to them.

  • /app/ is the read-only application directory for the running AIR application.
  • /app-storage/ is the read-write application storage directory for the running AIR application.
  • /home/ is the read-write user directory.
  • /tmp/ is the read-write temporary directory for the running AIR application.
  • /volumes/ is the read-only directory containing zero or more read-write subdirectories that represent mounted volumes.

If an app tries to access any other directory, the runtime throws an exception that the ActionScript code can catch.

As with AIR applications targeting other devices, it’s a best practice to use the following File class properties rather than a directory name:

  • File.applicationDirectory maps to the application’s application-specific directory.  The File.nativePath value of File.applicationDirectory  is /app/ in AIR for TV.
  • File.applicationStorageDirectory maps to an application-specific directory within a user-specific directory.  Its File.nativePath value is /app-storage/ in AIR for TV.
  • File.desktopDirectory maps to an application-specific directory within a user-specific directory.  Its File.nativePath value is /home/ in AIR for TV.
  • File.userDirectory maps to an application-specific directory within a user-specific directory. Its File.nativePath value is /home/ in AIR for TV.
  • File.documentsDirectory maps to an application-specific directory within a user-specific directory. Its File.nativePath value is /home/ in AIR for TV.

Note that File.desktopDirectory, File.userDirectory, and File.documentsDirectory all map to the same directory, which has the File.nativePath value  /home/.

Also consider the behavior of the following methods on AIR for TV devices:

  • File.createTempDirectory() creates a directory with the File.nativePath value /tmp/. AIR for TV maps /tmp/ to a temporary directory on the device. AIR for TV deletes this directory and its contents when the AIR application exits.
  • File.createTempFile() creates a file in the /tmp/ directory.
  • File.getRootDirectories()returns an array with one File object. The File object’s nativePath property has the value /. This root directory contains the directories app, app-storage, home and tmp.
  • StorageVolumeInfo.storageVolumeInfo.getStorageVolumes() returns a Vector of StorageVolume objects. Each StorageVolume object’s rootDirectory property is a File object. The File object’s nativePath value begins with /volumes/. All applications and users have access to the /volumes/ directory.

Contest for improving US government websites

Use your programming skills and web design know-how to help the US government improve its websites!

Adobe is a platinum sponsor for a contest called Design for America. The goal of the contest is to show government agencies better ways to present information to the public. Winners get cash awards and will have their entries showcased at the Gov 2.0 Expo in May in Washington, DC.

For details, visit this site:

http://blogs.adobe.com/adobeingovernment/2010/03/design_for_america.html

Sorting an array without sorting it

Have you ever wanted to access an array in a different sequence without
changing its current sequence? The ActionScript 3.0 constant, Array.RETURNINDEXEDARRAY, allows you to do that. When you call Array.sort() with RETURNINDEXEDARRAY as a parameter, sort() returns an array of indexes in sorted order. You can then use the indexed array to access the primary array in that sequence. The following example contains an array of students’ names: John, Rachel, Melissa, Calvin. Let’s say this sequence represents their order for the seating chart. Now, however, we would
like to get them in alphabetical order for the grade book. We can do this by calling students.sort(Array.RETURNINDEXEDARRAY) and using the indexed array that it returns. Note that by default, sort() sorts in ascending order. Here’s the code:

var students:Array = ["John", "Rachel", "Melissa", "Calvin"];
var index:Array = students.sort(Array.RETURNINDEXEDARRAY);
for(var i:int = 0; i < students.length; i++) {
trace(students[index[i]] + ": student index: "
+ index[i] + " sorted: " + i);
}

The example uses a for() loop to step through the returned index array in order, using the variable i, initialized to 0. The trace() statement displays the following information: the student’s name (students[index[i]]); the position of that student in the original array (the value of index[i]); the sorted position of the student, which is the sequence of index, or the value of i. The output looks like this:

Calvin: student index: 3 sorted: 0
John: student index: 0 sorted: 1
Melissa: student index: 2 sorted: 2
Rachel: student index: 1 sorted: 3

And the order of the students array remains unchanged: John, Rachel, Melissa, Calvin.

You can obtain additional sequences by using the OR operator| to combine
RETURNINDEXEDARRAY with other sort() constants. For example, the call to students.sort() in the following code combines RETURNINDEXEDARRAY with the constant DESCENDING, to access students in descending order:

var students:Array = ["John", "Rachel", "Melissa", "Calvin"];
var index:Array = students.sort(Array.RETURNINDEXEDARRAY | Array.DESCENDING);
for(var i:int = 0; i < students.length; i++) {
trace(students[index[i]] + ": student index: "
+ index[i] + " sorted: " + i);
}

The output for this version looks like this:

Rachel: student index: 1 sorted: 0
Melissa: student index: 2 sorted: 1
John: student index: 0 sorted: 2
Calvin: student index: 3 sorted: 3

For more information on the Array class, see:
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/Array.html