Archive for category AS3

Using New Flash Player Features

Tags: ,

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.

Read the rest of this article »

8 Comments

Maps With Int Keys: Array vs. Dictionary

Tags: , , , , , ,

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!

Read the rest of this article »

7 Comments

Converting Numbers to Ints

Tags: , , , , , ,

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!

Read the rest of this article »

14 Comments

Faster Log10

Tags: , , , ,

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!

Read the rest of this article »

11 Comments

Bitwise Alternatives to Multiply, Divide, and Modulus: Faster?

Tags: , ,

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!

Read the rest of this article »

15 Comments

Faster Math.abs

Tags: , , ,

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.

Read the rest of this article »

18 Comments

Faster isEven

Tags: ,

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.

Read the rest of this article »

9 Comments

Procedurally-Generated Shape Collection

Tags: , , , , ,

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.

Read the rest of this article »

5 Comments

Procedurally-Generated Cylinder

Tags: , , ,

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!

Read the rest of this article »

1 Comment

Stage3D Picking: Mouse and Touch Interaction

Tags:

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.

Read the rest of this article »

14 Comments