Archive for the 'Design Patterns' Category

Singleton Enforcer AS3
Thursday, January 17th, 2008

Just a helpful way to do Singleton’s in AS3 since there is no longer private constructors:
package
{
   public class SingletonClass
   {
      private static var INSTANCE : SingletonClass
      public function SingletonClass(enforcer:SingletonEnforcer)
      { // construction }
      public static function getInstance(): SingletonClass
      {
         if(INSTANCE == null)
         {
            INSTANCE = new SingletonClass(new SingletonEnforcer());
         }
         return INSTANCE;
      }
   }
}
class SingletonEnforcer{}

State Pattern in Games
Saturday, June 9th, 2007

The state pattern introduced by the gang of four in the mid-nineties is one of many useful methodologies. Since this is a Flash game programming blog I will be hitting a bunch of these patterns seeing as game programming can be some of the most complex and intricate around.
The state pattern can […]

Factory Pattern in Flash Games
Saturday, June 2nd, 2007

Creating enemies, agents or whatever is an important aspect of gaming. Having a class that creates a type of enemy should be quite easy. Just create a class of that type and action it’s supposed to do and use the “new” operator, throw it some params and away you go. Seems pretty […]