Proper private constructors for ActionScript 3.0

Here’s a useful tip for Flash and Flex programmers. ActionScript 3.0 is great, but has no Singletons.

Samuel Agesilas has a solution that successfully prevents subclasses from calling the constructor using super(), but it doesn’t prevent other code from creating new instances of a class with new

Therefore I present to you a crafty hack to make a constructor truly private: add a required argument to the constructor, which must be set to a secret value that is only known to the class:

Continue reading Proper private constructors for ActionScript 3.0