Archive for category AS3

PNG, JPEG, and JPEG-XR Compression and Decompression Performance

Tags: , , , , ,

Are you using the fastest assets you can? Yes, even the file format of the assets you use has a big bearing on the performance of your app. Ask yourself: is PNG faster to decompress than JPEG? Is it faster to compress to JPEG-XR or PNG? Do the quality settings matter? Today’s article explores the performance of Flash’s main three image formats—PNG, JPEG, and JPEG-XR—to find out which decompresses fastest at load time and compresses fastest at save time.

Read the rest of this article »

7 Comments

How To Reclaim Hidden Unused Bitmap Memory

Tags: , , ,

As I discovered in the previous articles, loaded bitmaps are stored in memory in two forms: the compressed PNG, JPEG, JPEG-XR, GIF file and the uncompressed RGBA pixels. If you don’t use the pixels, Flash Player will reclaim its memory and then uncompress it if you use the bitmap later on. However, if you do plan to use the bitmap, isn’t the compressed file data just memory overhead? Today’s article will show you how to dump this unused file data and save a bunch of memory.

Read the rest of this article »

3 Comments

Keeping Bitmaps Decompressed

Tags: , , ,

It came to my attention in the comments of Preloading Bitmap Decompression that Flash Player would actually free the decompressed bitmap memory if you didn’t make active use of it, similar to garbage collection. So if you followed my strategy from that article to preload a bitmap, it may have been un-preloaded for you by Flash Player! Today’s article shows you how to work around this little problem.

Read the rest of this article »

22 Comments

String-Sortable Integers

Tags: , , ,

Strings and integers sort differently. Unfortunately, this became a problem for me during some recent experiments with Starling. It could be a problem for you too in a variety of situations. Today we’ll look at a workaround I’ve developed to solve this problem, which isn’t nearly as straightforward as you might think.

Read the rest of this article »

7 Comments

Rendering Spriter Sprites With Starling

Tags: , ,

Spriter is a tool for creating sprite animations out of multiple images. By moving, rotating, and scaling them over a timeline you can create much more efficient 2D animations than traditional full-frame animation. While Flash animation has worked similarly for years, it’s largely incompatible with the Stage3D API that is quickly becoming mandatory to achieve adequate performance. Today’s article will show you how to use Spriter in your Stage3D-powered Flash app via a Starling and some custom classes I’ve created.

Read the rest of this article »

5 Comments

Handling Stage3D Context Loss

Tags: , ,

Context loss with Stage3D is real and will instantly take down your 3D scene. It’s an unavoidable problem, but one that many programmers still don’t handle gracefully. How does it occur? Why does it matter? How can you handle it so your app continues to function well? Today’s article explores the topic of Stage3D context loss so you can keep your 3D scene alive and well.

Read the rest of this article »

8 Comments

Preloading Bitmap Decompression

Tags: , , ,

Since they were introduced way back in Flash Player 8, bitmaps have become a core feature in almost all Flash apps. The way you handle them—creation, operations, and destroying—is one of the most important factors determining your app’s performance. Today’s article shows one little-known trick to help out the performance of loading and using bitmaps.

Read the rest of this article »

10 Comments

Three Interesting Discoveries

Tags: , , ,

Today’s article is about three totally unrelated discoveries I’ve recently made in AS3. These answer three questions I’ve recently had. Should you cache the object you’re looping over with a for-each loop as a local variable? Can you clear a Dictionary or Object with a for-in loop? Is it faster to write your own version of Vector.indexOf? All of these questions are answered in today’s article!

Read the rest of this article »

9 Comments

System RAM and VRAM Explained

Tags: , , , , , ,

I’ve mentioned the concept of VRAM (video memory) in a few articles, but I still find constant confusion among readers of this site as well as coworkers and colleagues in day-to-day work with Stage3D. Today’s article will hopefully clear up the differences, dispel some myths, and help you make the best use of both of them.

Read the rest of this article »

13 Comments

Using ATF Is Harder Than You Might Think

Tags: , , , ,

Using Adobe’s new compressed texture format should be as simple as replacing some PNG and JPEG images with ATFs their tools created, but it’s not. If you don’t know what you’re doing, the process can be pretty confusing. Today’s article walks you through the steps to upgrade a Stage3D-using app to make use of ATF textures.

Read the rest of this article »

16 Comments