Posts tagged "ActionScript"

CPU optimization tips for the Adobe Flash Platform

Optimizing Performance for the Adobe Flash Platform contains a treasure trove of tips on less obvious performance enhancements. For example, chapter 3, “Minimizing CPU usage”, highlights the following CPU management features:

  • Pause and resume SWF files based on screen exposure: This is an automatic feature in Flash Player since version 10.1. Flash Player minimizes processing when SWF content goes off-screen.
  • Instance management: This feature introduced the hasPriority HTML parameter. By default, Flash Player doesn’t start SWF content that is not visible. You can override this behavior in most cases by using the hasPriority parameter.
  • Sleep mode: On mobile devices, Flash Player and AIR detect when the device backlight goes into sleep mode. When this event occurs, rendering of SWF content stops, and frame rates drop to 4fps. Because the frame rate stays above zero, all open data connections can remain open.
  • Freezing and unfreezing objects: You can use REMOVED_FROM_STAGE and ADDED_TO_STAGE events to keep objects that are no longer in the display list from consuming unnecessary CPU cycles.
  • Activate and deactivate events: By using events to detect when your application is activated or deactivated, you can reset the frame rate, freeze or unfreeze objects, or perform other CPU optimizations.
  • Mouse interactions: Detecting mouse interaction on many objects simultaneously can be CPU-intensive. You can reduce that overhead by disabling mouse interactions on objects that do not respond to mouse events.
  • Timers versus ENTER_FRAME events: To execute code at specific intervals you can choose between a timer or ENTER_FRAME events. The optimal choice for your situation depends on a number of factors, such as whether your application uses animation.
  • Tweening syndrome: Minimize the use of tweens, especially for content intended for low-performance mobile devices.

Visit the Optimization Guide to find out more about these topics and many others, including memory management, efficient use of the ActionScript language, rendering, networking, and database access.

Starling example hints

Problems building and debugging the Starling example on Adobe Developer Connection? This blog posting might help.

Looking for ActionScript examples? Try this

There are tons of awesome code snippets and examples in the ActionScript Reference and ActionScript Developer guide. Learn about the enhancements we’re working to make it easier to find examples: http://e-musings.tumblr.com/post/11670105969/looking-for-actionscript-examples-try-this

Native JSON API released

The Flash Player 11/AIR 3.0 (Serrano) release fulfills a long-standing developer request by introducing a native ActionScript JSON API. With this API, you can import and export objects using JSON encoding. Native JSON functionality correlates closely with the ECMA-262 (5.1 Edition) specification for JSON. Because of this, its syntax is somewhat different from the third-party as3corelib JSON library. You can find out more about these differences in community member Todd Anderson’s blog posting at the Infrared5 company blog.

The API itself consists of a top-level class named JSON. This class provides two methods: stringify() for encoding, and parse() for decoding JSON strings. The JSON feature also supports toJSON() member functions in any class. Visit the official documentation at these locations:

ActionScript 3.0 Reference
ActionScript 3.0 Developer’s Guide

Native extension detailed documentation

With the announcement of AIR 3 and its new native extension feature, detailed documentation about using Native Extensions for Adobe AIR is available now at:

Developing native extensions for Adobe AIR

You’ll find:

– Overview and conceptual information

– How to use the C and Java native extension APIs, plus reference pages

– How to package your native extension using ADT

– Details on the Extension Descriptor file

– Information on using Android shared libraries, and using resources on Android and iOS

If you are using a native extension in your AIR application, see:

Using native extensions in AIR applications

For lots of examples and tutorials, see this Adobe Developer Connection page:

http://www.adobe.com/devnet/air/native-extensions-for-air.htm

 

 

Adobe Cookbook recipe challenge begins!

Got a tasty tip or technique to offer to the Flash Platform developer community? Want a shot at winning a Samsung 10.1 tablet? If so, head on over to the Adobe Developer Center and learn more about the Adobe Cookbook recipe request challenge: http://adobe.ly/ot8Eoy. Everyone who responds to the challenge by contributing a cookbook recipe gets an Adobe Developer Connection T-shirt, plus a chance to win the tablet. Good luck!

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.

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.

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

H/W accelerate your video performance: Flash Player 10.2 StageVideo docs are live

Does your Flash Player application feature a video player? And if so, are you looking for a way to improve the video performance?

For several releases, Flash Player has supported GPU hardware acceleration for decoding H.264 videos. However, the rest of the rendering process still required the CPU. Flash Player 10.2 brings hardware acceleration support full circle by introducing the StageVideo API. Stage video lets you apply hardware acceleration to the entire video decoding and rendering process, thus freeing up CPU and memory resources.

A StageVideo API has previously been available only to AIR 2.5 for TV application developers, and through the Flash 10.1 Beta for Google TV. The StageVideo API in Flash Player 10.2 expands on these existing classes. It adds events for handling behavior in a browser context.

To learn how your application can take advantage of this new feature, see the following documentation: