Vector.sort() documentation update

A community member  pointed out recently that the ActionScript Language Reference description for Vector.sort() is incomplete. The reference will be updated soon. In the meantime, here’s the corrected description, which now includes sorting according to a “sort option” as well as sorting by using a compare function.

Vector sort() method:

Sorts the elements in the Vector object, and also returns a sorted Vector object. This method sorts according to the parameter sortBehavior, which is either a function that compares two values, or a set of sorting options.

The method takes one parameter. The parameter is one of the following:

  • a function that takes two arguments of the base type (T) of the Vector and returns a Number:

function compare(x:T, y:T):Number {}

The logic of the function is that, given two elements x and y, the function returns one of the following three values:

  • a negative number, if x should appear before y in the sorted sequence
  • 0, if x equals y
  • a positive number, if x should appear after y in the sorted sequence
  • a number which is a bitwise OR of the following values:
  • 1 or Array.CASEINSENSITIVE
  • 2 or Array.DESCENDING
  • 4 or Array.UNIQUESORT
  • 8 or Array.RETURNINDEXEDARRAY
  • 16 or Array.NUMERIC

If the value is 0, the sort works in the following way:

  • Sorting is case-sensitive (Z precedes a).
  • Sorting is ascending (a precedes b).
  • The array is modified to reflect the sort order; multiple elements that have identical sort fields are placed consecutively in the sorted array in no particular order.
  • All elements, regardless of data type, are sorted as if they were strings, so 100 precedes 99, because “1″ is a lower string value than “9″.

Parameters
sortBehavior:* — A Function or a Number value that determines the behavior of the sort. A Function parameter specifies a comparison method. A Number value specifies the sorting options.

Returns
Vector  — A Vector object, with elements in the new order.

AIR for TV application documentation updates

Updates are now available to Developing AIR applications for television devices in Building Adobe AIR Applications on Adobe.com.

These updates include:

  • Design considerations. Remember all the entries on this blog that talked about various design considerations for AIR for TV apps? Now those tips plus others are available in the online documentation.
  • How to use Adobe Flash Professional CS5 and Adobe Flash Builder 4.5 to develop your AIR for TV application. This information includes how to build an application that uses an ActionScript extension.
  • How to use ADT to package an AIR for TV application that uses an ActionScript extension.
  • How to use ADL to test an AIR for TV application that uses an ActionScript extension.
  • General information on how to remotely debug an AIR for TV application running on the device. However, detailed steps depend on the device.

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.

Managing graphics memory in AIR for TV apps

And here’s one more design consideration for AIR for TV application development…

This one continues the discussion from the blog entry called Using Graphics Hardware Acceleration in AIR for TV Apps.

To perform the accelerated graphics operations, hardware accelerators use special graphics memory. If your
application uses all the graphics memory, the application runs more slowly because AIR for TV reverts to using
software for the graphics operations.

To manage your application’s use of graphics memory:

  • When you are done using an image or other bitmap data, release its associated graphics memory. To do so, call the dispose() method of the bitmapData property of the Bitmap object. For example:

myBitmap.bitmapData.dispose();

Note: Releasing the reference to the BitmapData object does not immediately free the graphics memory. The runtime’s garbage collector eventually frees the graphics memory, but calling dispose() gives your application more control.

  • Use PerfMaster Deluxe, an AIR application that Adobe provides, to better understand the impact of hardware graphics acceleration on your target device. This application shows the frames per second to execute various operations. Use PerfMaster Deluxe to compare different implementations of the same operation.  For example, compare moving a bitmap image versus moving a vector image. PerfMaster Deluxe is available with the Adobe® AIR® for TV MAX 2010 Hardware Developer Kit, and will soon be available at Flash Platform so you can use it with other devices, too.

And don’t forget: Do not keep bitmap objects, or any objects, on the display list when they are not visible. Whether software or hardware renders a display object, rendering it when it is not visible needlessly uses resources to render the object. If you have a good reason to hold onto a display object when it is not visible, remove the object from the display list. This best practice applies not only for AIR for TV apps, but AIR apps and Flash Player apps on all devices (mobile, desktop, tablet, and TVs).

UI personality for AIR for TV applications

Here’s another user interface design consideration for AIR for TV applications. (This and other tips will be incorporated soon into Adobe online documentation).

This tip considers that users of AIR for TV applications are typically seeking TV quality entertainment in a fun and relaxed environment. They are not necessarily knowledgeable about computers or technology.

Therefore, design AIR for TV applications with the following characteristics:

  • Do not use technical terms.
  •  

  • Avoid modal dialogs.  Modal dialogs confuse some users.
  •  

  • Use friendly, informal instructions appropriate for a living room environment, not a work or technical environment.
  •  

  • Use graphics that have the high production quality that TV watchers expect.

 

     

    Usability of your AIR for TV application

    Here’s another design consideration for the user interface of AIR for TV applications. (This and other tips will be incorporated soon into Adobe online documentation).

    Users of AIR for TV applications are in a “living room” environment. They are sitting across the room from the TV, some 10 feet away. The room is sometimes dark. They typically use a remote control device for input. More than one person can be using the application, sometimes together, sometimes serially.

    Therefore, to design your user interface for usability on a TV, consider the following:

    • Make the user interface elements large.This best practice might be obvious to many developers, but the temptation does exist to crowd the screen just because the screen has so much space.  Don’t give in to this temptation. When designing text, buttons, or any other user interface elements, consider that the user is sitting across the room. Make everything easy to see and read from, for example, 10 feet away. 
    • Use good contrast to make the content easy to see and read from across the room.
    •  

    • Make obvious which user interface element has the focus by making that element bright.  See the blog entry from March 8 about Managing Focus.
    •  

    • Use motion only as necessary. For example, sliding from one screen to the next for continuity can work well. However, motion can be distracting if it does not help the user navigate or if it is not intrinsic to the application.
    •  

    • Always provide an obvious way for the user to go back through the user interface.

    Using graphics hardware acceleration in AIR for TV apps

    And here is yet one more tip from soon-to-be-available-at-adobe.com documentation about AIR for TV application development.

    AIR for TV devices provide hardware acceleration for 2D graphics operations. The device’s hardware graphics accelerators off-load the CPU to perform the following operations:

    • Bitmap rendering
    • Bitmap scaling
    • Bitmap blending
    • Solid rectangle filling

    This hardware graphics acceleration means many graphics operations in an AIR for TV application can be high performing. Some of these operations include:

    • Sliding transitions
    • Scaling transitions
    • Fading in and out
    • Compositing multiple images with alpha

    To get the performance benefits of hardware graphics acceleration for these types of operations, use one of the following techniques:

    • Set the cacheAsBitmap property to true on MovieClip objects and other display objects that have content that is mostly unchanging. Then perform sliding transitions, fading transitions, and alpha blending on these objects.
    • Use the cacheAsBitmapMatrix property on display objects you want to scale or translate (apply x and y repositioning).

      By using Matrix class operations for scaling and translation, the device’s hardware accelerators perform the operations. Alternatively, consider the scenario where you change the dimensions of a display object that has its cacheAsBitmap property set to true. When the dimensions change, the runtime’s software redraws the bitmap. Redrawing with software yields poorer performance than scaling with hardware acceleration by using a Matrix operation.

      For example, consider an application that displays an image that expands when an end user selects it. Use the Matrix scale operation multiple times to give the illusion of the image expanding. However, depending on the size of the original image and final image, the quality of the final image can be unacceptable. Therefore, reset the dimensions of the display object after the expanding operations are completed. Because cacheAsBitmap is true, the runtime software redraws the display object, but only once, and it renders a high-quality image.

      Note: Typically, AIR for TV devices do not support hardware-accelerated rotation and skewing. Therefore, if you specify rotation and skewing in the Matrix class, AIR for TV performs all the Matrix operations in the software. These software operations can have a detrimental impact to performance.
    • Use the BitmapData class to create custom bitmap caching behavior.

     

    User interface responsiveness in AIR for TV applications

    Here’s another design consideration for AIR for TV applications. (This and other tips will be incorporated soon into Adobe online documentation).

    Use the following tips to make an AIR for TV application as responsive as possible.

    • Make the application’s initial SWF file as small as possible.

      In the initial SWF file, load only the necessary resources to start the application. For example, load only the application’s startup screen image.

      Although this recommendation is valid for desktop AIR applications, it is more important on AIR for TV devices. For example, AIR for TV devices do not have the equivalent processing power of desktop computers. Also, they store the application in flash memory, which is not as fast to access as hard disks on desktop computers.
    • Make the application run at a frame rate of at least 20 frames per second.

      Design your graphics to achieve this goal. The complexity of your graphics operations can affect your frames per second. For tips on improving rendering performance, see Optimizing Performance for the Adobe Flash Platform.

      Note that the graphics hardware on AIR for TV devices typically updates the screen at a rate of 60 Hz or 120 Hz (60 or 120 times per second). The hardware scans the stage for updates at, for example, 30 frames per second or 60 frames per second for display on the 60-Hz or 120-Hz screen. However, whether the user experiences these higher frame rates depends on the complexity of the application’s graphics operations.

      Stay tuned for an upcoming blog entry discussing what the graphics hardware accelerators on AIR for TV devices do well, and how to take advantage of them.

    • Update the screen within 100 – 200 milliseconds of user input.

      Users become impatient if updates take longer, often resulting in multiple keypresses.

    Now available: Flash Player 10.3 Beta for Windows, Mac, and Linux

    Flash Player 10.3 beta software is ready for download at Adobe Labs! Flash Player 10.3 provides key features for developers, content publishers, and end-users. Adobe urges the developer community and technically savvy users to test these new features, which include:

    • Media measurement — Implement your own video analytics.
    • Acoustic echo cancellation — Create real-time online collaboration experiences that provide high-quality audio without requiring a headset.
    • Integration with browser privacy controls for managing local storage — Users can easily clear local storage from the browser settings interface.
    • Native Control Panel — New streamlined controls make it easier to manage Flash Player privacy, security, and storage settings.
    • Auto-update notification for Mac OS — Mac users: Get automatic notification of Flash Player updates on Mac OS, and stay current with the latest capabilities.

    Flash Player 10.3 beta supports these features on the desktop. Adobe plans to bring them to mobile devices in the future.

    Watch upcoming entries on our blog for more detailed descriptions. Also, stay tuned for a new posting of the Adobe ActionScript 3.0 Reference that describes Flash Player 10.3 APIs.

    See the official FAQ: http://icomm.corp.adobe.com/Library/?pid=55466

    Managing focus in AIR for TV applications

    Here’s another design consideration for AIR for TV applications. (This and other tips will be incorporated soon into Adobe online documentation).

    When a user interface element has the focus in a desktop application, it is the target of user input events such as keyboard and mouse events. Furthermore, an application highlights the user interface element with the focus. Managing focus in an AIR for TV application is different from managing focus in a desktop application because:

    • Desktop applications often use the tab key to change focus to the next user interface element. Using the tab key doesn’t apply to AIR for TV applications. Remote control devices do not typically have a tab key. Therefore, managing focus with the tabEnabled property of a DisplayObject like on the desktop does not apply.
    • Desktop applications often expect the user to use the mouse to give focus to a user interface element.

    Therefore, in your application, do the following:

    • Add an event listener to the Stage that listens for Keyboard events such as
      KeyboardEvent.KEY_DOWN.
    • Provide application logic to determine which user interface element to highlight to the end user. Be sure to highlight a user interface element when the application starts.
    • Based on your application logic, dispatch the Keyboard event that the Stage received to the appropriate user interface element object.

      You can also use Stage.focus or Stage.assignFocus() to assign the focus to a user interface element. You can then add an event listener to that DisplayObject so that it receives keyboard events.