The Display List
The structure of your display list is fundamental in this process for three reasons: memory consumption, tree traversal, and node hierarchy.
Memory Consumption
Memory consumption is the trade-off for better performance in GPU rendering because every off-screen bitmap uses memory. At the same time, mobile development implies less GPU memory caching and RAM.
To get a sense of the memory allocated, you can use the following formula:
// 4 bytes are required to store a single 32 bit pixel // width and height of the tile created // anti-aliasing defaults to high or 4 in Android 4 * width * height * anti-aliasFactor A 10 × 10 image represents 1600 bytes
Be vigilant about saving memory in other areas.
Favor the DisplayObject
types
that need less memory. If the functionality is sufficient for your
application, use a Shape
or a
Sprite
instead of a MovieClip
. To determine the size of an
object, use the following:
import flash.sampler.*; var shape:Shape = new Shape(); var sprite:Sprite = new Sprite(); var mc:MovieClip = new MovieClip(); trace(getSize(shape), getSize(sprite), getSize(mc)); // 224, 412 and 448 bytes respectively in the AIR runtime
The process of creating and removing objects has an impact on performance. For display objects, use object pooling, a method whereby you create a defined number of objects up front and recycle them as needed. Instead of deleting them, make them invisible or remove them from the display list until you need to use them again. I will demonstrate ...
Get Developing Android Applications with Adobe AIR now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.