Adobe adds new features to every new version of Flash Player. To use these features, you have to compile your SWF correctly. Unfortunately, setting up your build environment and passing the right options to the compiler can be a bit tricky. Today’s article attempts to clear up the confusion so you can take advantage of the latest Flash Player features.
Archive for category AS3
Behind the scenes Array
holds its values in two ways: a densely-packed array at the beginning and a sparsely-packed map after that. This means it can be used as a map where the keys are indexes and not take up a huge amount of wasted space. Dictionary
can also have int
keys. Which is faster? Today we’ll find out!
This is an extremely common task: converting a Number
to an int
. There are a lot of ways to do it, but which is fastest in AS3? Today we’ll look at a performance test app that attempts to find the fastest way to accomplish this. The answer just may surprise you!
Today’s article is quick and to the point: when you need to take the base 10 logarithm of an integer you can speed this up by about 8x. Read on for the technique and save some CPU cycles!
Many programmers are aware of a special case where you can use a bitwise shift for multiplication or division when you’re multiplying or dividing by a power of two. For example, you can replace i * 2
with i << 1
and i / 2
with i >> 1
. A lesser-known trick works for modulus. But are these alternatives actually any faster? Today's article puts them to the test!
Math.abs
is a commonly-used utility function for taking the absolute value of a Number
. However, there’s no special-case version for taking the absolute value of an int
. Of course Math.abs
will work for int
values, but we can do it faster. Read on for a couple of ways.
A common programming task is to determine if an integer is even or odd. Recently, I saw an article showing how to do the task faster than the usual way: (i % 2) == 0
. Today’s article shows an even faster way to check for even or odd.
Today’s article presents a collection of procedurally-generated 3D shapes for Stage3D
. In addition to spheres and cylinders, I’ve added circles, pyramids, cubes, and quads to the mix and refactored them all to inherit from a new Shape3D
class. Read on for the full source code for all of these as well as a demo app.
A couple of weeks ago I presented a procedurally-generated sphere for Stage3D
. Today I have one more procedurally-generated model for you: a cylinder. Cylinders are useful for a variety of purposes, especially during debugging. For example, you can use them to show the direction a player’s gun is pointing or to construct a simple X, Y, Z axis display. Read on for the source code and a demo app!
Virtually every 3D app or game will need to support mouse or touch interaction with the 3D scene. Consider a real-time strategy game like StarCraft where clicking on units is essential to the gameplay. Check out the Stage3D
API and you’ll quickly realize that there’s zero functionality to handling mouse or touch events. So how do all of these games handle it? The answer is a technique called “picking” and this article will show you how to implement it.