Archive for category AS3

Pseudo Threads

Tags: , , ,

Eventually, Flash Player will support Worker Threads to take advantage of multi-core CPUs, but that may be quite a while from now. Today’s article shows you how you can get some concurrency right now by faking threads. Read on for the technique!

Read the rest of this article »

18 Comments

Composing BitmapData Scenes

Tags: , ,

Since Flash 8, BitmapData has offered a wide range of possibilities to improve performance. Many Flash apps, particularly games, choose to simply display a single, huge BitmapData, render the entire game scene into it and, for the most part, eschew Stage‘s whole system of DisplayObject and DisplayObjectContainer. When you’re doing this or just generally using BitmapData for more than just raster (e.g. JPEG, PNG) image display, you should know your options for composing a BitmapData out of other BitmapData. Today’s article discussing the performance of the two main ways of composing these BitmapData scenes: BitmapData.draw and BitmapData.copyPixels.

Read the rest of this article »

13 Comments

Typesafe Dictionary

Tags: , , , ,

One of the advantages of using Dictionary instead of Object when mapping key-value pairs is that you can use whatever type of key you want, not just a String. However, a recent comment points out that the keys are still checked with the loose equality operator (==) and you can therefore get clashes like 4 == "4". For today’s article, I’ve written a TypesafeDictionary class that allows you to overcome this limitation. Read on for the implementation, performance testing, and more.

Read the rest of this article »

4 Comments

Proxy Performance

Tags: , , , ,

The Flash API has a gem of a class in Proxy. You can use it to customize the behavior of the dot (.), index ([]), delete, and in operators as well as the for-in and for-each-in loops. Today’s article answers a recent comment by exploring the performance implications of all this fancy customizing that Proxy allows.

Read the rest of this article »

2 Comments

Dictionary Memory Leak

Tags: , ,

The Dictionary class provides perhaps the most useful support for weak references—and therefore garbage collection control—in the AS3 Flash API. However, due to a subtle error in its documentation, you may inadvertently be leaking a lot of memory. Today’s article shows you how this can happen and how you can easily fix the leak.

Read the rest of this article »

23 Comments

Casting Questions Answered

Tags: , , , ,

You, my dear readers, have posed many fine questions and chimed in with many excellent suggestions to my previous articles on typecasting and today I will answer them! (for newcomers to this series, read on for tips showing how to easily speed up your casts by 200x or more)

Read the rest of this article »

9 Comments

What is an int?

Tags: , , , ,

If you’re thinking “I know what an int is”, you need to take this little quiz to find out for sure!

Read the rest of this article »

6 Comments

Faster Logic With Bitwise Operators

Tags: , , , , ,

Logical operators are necessary in every app, so it’s unfortunate that they are so slow in AS3. That’s why I was happy to see a potential alternative in a recent comment by Skyboy. Today’s article shows you how to do logic faster by avoiding logical operators (e.g. &&) and using their bitwise (e.g. &) operator counterparts instead.

Read the rest of this article »

25 Comments

Fast AS3 MultiMap

Tags: , , , ,

Sometimes you need to map a key to many values, but AS3 has no built-in data structure for this purpose. Dictionary and Object are suitable one-to-one maps, but there’s been no one-to-many support until now. Read on for my own one-to-many class—MultiMap—as well as performance testing and analysis.

Read the rest of this article »

39 Comments

Amazing Lookups Optimization

Tags: , , , , ,

Today’s article is about an unintuitive-yet-simple optimization you can use to hugely increase the speed of reading from Array, Vector, Dictionary, Object, and dynamic classes. Need I say more? Read on for this amazing speedup!

Read the rest of this article »

59 Comments