Posted By

GunnarHKarlsson on 09/28/11


Tagged

event Singleton


Versions (?)

EventCentral


 / Published in: ActionScript 3
 

  1. package com.squidzoo.eventSystem {
  2.  
  3. import flash.events.*;
  4.  
  5. public class EventCentral extends EventDispatcher {
  6.  
  7. private static var instance:EventCentral;
  8.  
  9. public function EventCentral(blocker:SingletonBlocker):void{
  10. super();
  11. if (blocker == null) {
  12. throw new Error("Error: instantiation failed; Use EventCentral.getInstance()");
  13. }
  14. }
  15.  
  16. public static function getInstance():EventCentral {
  17. if (instance == null){
  18. instance = new EventCentral(new SingletonBlocker());
  19. }
  20. return instance;
  21. }
  22.  
  23. public override function dispatchEvent(event:Event):Boolean{
  24. return super.dispatchEvent(event);
  25. }
  26. }
  27. }
  28.  
  29. internal class SingletonBlocker {}

Report this snippet  

You need to login to post a comment.