Posts tagged as 'Actionscript'
Keyboard polling class – bug fix
There was an error in the Keyboard polling class that I posted yesterday. If you downloaded the class you’ll want the new version, which is available here.
Posted on 4 September 2007 | no comments | continue reading
Polling the keyboard in Actionscript 3
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…
Posted on 3 September 2007 | no comments | continue reading
Events in Actionscript 3
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…
Posted on 15 August 2007 | 1 comment | continue reading
Different types of weak references
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…
Posted on 15 August 2007 | no comments | continue reading
Creating weak references in Actionscript 3
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. Well, there is a way. It’s a bit of a hack, and unfortunately uses a full Dictionary object for each weak reference, but it works. The source code is very short…
Posted on 15 August 2007 | 1 comment | continue reading
Events in Actionscript 2
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.
Posted on 14 August 2007 | 5 comments | continue reading
Singleton Factory
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…
Posted on 27 July 2007 | 7 comments | continue reading
Physics for Flash Games: Slides
It was great to see so many people at my presentation yesterday at LFPUG. The presentation seemed to go down very well and I had a great evening. Here’s the slides from my presentation. If you weren’t there, they may not make a lot of sense without my talking over the top of them, but I suspect lots of people who were there want to look at the code again.
Posted on 1 June 2007 | 7 comments | continue reading
