Archive for September, 2009

Introducing the ActionScript 3.0 Reference for the Adobe Flash Platform

We’ve just released a beta version of something that we’re all very excited about – the ActionScript 3.0 Reference for the Adobe Flash Platform. What’s the big deal? It’s all the APIs and core AS3 language stuff in one place. Today, tomorrow, forever. One URL to bookmark. One destination for Flash Player, AIR, ColdFusion, LiveCycle, Flash Professional, and Flex APIs. In addition to that, the content is filterable. You select the APIs you want to see in the reference. You can select APIs by runtime, by product, and by versions.

This is our first beta so we’d appreciate your feedback, particularly in these areas:

  • What do you think of the new structure of the reference? Please compare the experience of accessing all of the products and runtimes in one spot against the experience of using the separate product-specific language references we have published to date.
  • Is the content filtering feature useful? Content filtering lets you see only the products, runtimes, and versions you are interested in.

You can send us your feedback by using the feedback link in the version pod (top right popup in the reference).


The Adobe Flash Platform Documentation teams

Contribute your code examples to the new version of Adobe Cookbooks

The Adobe Developer Connection is excited to announce that the brand new Adobe Cookbooks application is now live! This uber Adobe Cookbook application replaces the individual, product-specific cookbook applications that were previously in place for Flex, AIR and Mobile. The new application will still support those technologies, in addition to a dozen or so additional technologies, all within a single application. For those new to the cookbook applications, they are a searchable repository for community-generated code samples.

You can read more about the new application in Ed Sullivan’s Logged In article on the Adobe Developer Connection.

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: