Screenwriter, Choreographer, Game Developer

Actionscript

Four ways to link a list (a performance test on linked list architectures)

Posted on

In looking at entity systems for Flash games, and particularly the projects Ember and Xember, I was wondering what is the most efficient architecture for the linked lists used by these systems. So I ran some tests. The code for these tests is all available on Github. The lists in these frameworks are used to manage the component sets for the systems that run the game. These lists need to provide three functions - add an item, remove an item, and loop through all the items, and they need to do this as efficiently as possible. So I created four different architectures for linked lists and ran a few performance tests. Continue reading →


The I in Interface

Posted on

I'm sometimes asked why the interfaces in Flint don't start with a letter I. The simple reason is that I think this practice, while common among Actionscript developers, is so seriously flawed that it's better not to do it, even if it is common among other developers and may cause some initial confusion for some. Continue reading →


Object Pool class

Posted on

Two of the slow operations in the Flash player are object creation and garbage collection. If we pool objects - save objects when they're no longer needed and reuse them later when another object of the same type is required - then object creation is kept to a minimum and garbage collection is reduced to zero. Continue reading →


The parentheses operator

Posted on

It's not uncommon for less experienced Actionscript developers, particularly self-taught developers, to be a little confused about the purpose of the parentheses you put after a function name when calling the function. The most common question is why aren't the parentheses used when assigning a function as an event handler?. Continue reading →


Radial Perlin Noise

Posted on

I was messing around with perlin noise, creating a radial effect for a game I'm working on. The result is a RadialPerlin class for creating radial perlin noise bitmaps. The code is licenced under the MIT license. Have fun, and if you make something interesting with it let me know. Continue reading →


Polling the keyboard in Actionscript 3

Posted on

Games often need to get the current state of various keys in order to respond to user input. This is not the same as responding to key down and key up events, but is rather a case of discovering if a particular key is currently pressed. In Actionscript 2 this was a simple matter of calling Key.isDown() with the appropriate key code. But in Actionscript 3 Key.isDown no longer exists and the only intrinsic way to react to the keyboard is via the key up and key down events. To rectify this I created the KeyPoll class. Continue reading →


Creating weak references in Actionscript 3

Posted on

A weak reference is a reference that does not prevent the object from being garbage collected. It's great that Actionscript 3 has weak references in the EventDispatcher and Dictionary classes. But sometimes you want to create your own weak references. The source code is very short. Continue reading →


Events in Actionscript 3

Posted on

There was lots of positive feedback to yesterday's post about my Actionscript 2 event class, so I decided to create an Actionscript 3 version. I added a lot of features while I was at it - listener priorities, preventDefault, stopNotification (aka stopImmediatePropagation), hasListeners, weak references, and to send the event as the single parameter when notifying listeners. Continue reading →


Different types of weak references

Posted on

Actionscript 3 seems to have two different types of weak references. The difference relates to method closures (or bound methods) and the weak references used by the EventDispatcher and Dictionary classes. Try the following. Continue reading →


Events in Actionscript 2

Posted on

I documented my technique for implementing event dispatching over on the Flash Game Code site. I've been using this method for a couple of years now and I think it's a lot better than EventDispatcher or ASBroadcaster. Take a look if your interested. Comments are welcome below. The source code is available for free on flashgamecode.net under the MIT licence. Continue reading →


Singleton Factory

Posted on

I've mentioned before how I dislike the Singleton pattern. So this morning I was experimenting with various other possible ways to create singletons in Actionscript 3 and came up with a function that can be used to create and reuse a single instance of any class. I don't know how useful it will turn out to be but here it is. It's also a useful example of a package level function. Continue reading →


List Loader for Actionscript 2

Posted on

It happened recently that I needed to load a list of items from a text file. There was no other structure to the file except that each item in the list was on a separate line. The items were not in XML and they were not in form variables format (used by LoadVars). Here's how it's done. Continue reading →


Simple example of acceleration

Posted on

While teaching my Actionscript Fundamentals course a couple of days ago one of the trainees asked me how to do a simple example of using acceleration and deceleration within an animation. Here it is. Continue reading →


Singletons - we're better off without them

Posted on

With the introduction of Actionscript 3 there was a lot of discussion about how to implement the singleton design pattern. This happened because Actionscript 3 doesn't allow private or protected constructors and this prevents the most common implementation technique for singletons. But singletons are never actually needed and are rarely a good idea. Continue reading →


Finite State Machines for AI in Actionscript

Posted on

A few months ago I said I'd post about the AI in Stick Sports Soccer. Here, at last, is the first such post looking at the code used to implement the Finite State Machines in this and other games I've developed. Continue reading →