AS3 Singleton - FDT Template
August 12th, 2008
Ok, here we go again, AS3 and Singletons have been discussed almost as much as Peak Oil, but never-the-less, allow me to present yet another Singleton implementation, wrapped up in a neat little FDT template.
package ${enclosing_package} {
/**
* @author ${user}
*/
public class ${enclosing_type} {
private static var _instance : ${enclosing_type};
private static function hidden() : void {}
public static function getInstance() : ${enclosing_type} {
if( _instance == null ) {
_instance =
new ${enclosing_type}(hidden);
}
return _instance;
}
public function ${enclosing_type} (h:Function) {
if (h !== hidden) {
throw new Error( "${enclosing_type} and can only be accessed through ${enclosing_type}.getInstance()" );
}
}
${cursor}
}
}
can you Digg it?
is it del.icio.us? 
Category: General



Leave a Comment
You must be logged in to post a comment .
Trackback this post | Subscribe to the comments via RSS Feed