Update: ActionScript 3 singleton pattern

In software engineering, the singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects (say, five). Some consider it an anti-pattern, judging that it is overused, introduces unnecessary limitations in situations where a sole instance of a class is not actually required, and introduces global state into an application. (wikipedia)

In search of the best actionscript 3 singleton pattern I came to this one. It uses private lock so user is not allowed to create new instance…

Read the rest of this entry »

private setter, public getter

It is possible to make private setter and public getter on actionscript classes. All you need is to use proper namespaces for getter and setter within the class.

Read the rest of this entry »