Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. /**
  2. * Created by soul on 22.01.15.
  3. */
  4. package agnidea.utils {
  5. import flash.utils.Dictionary;
  6.  
  7. import mvcexpress.core.messenger.Messenger;
  8.  
  9. public class AFn {
  10. private static var channels:Dictionary = new Dictionary();
  11. public static function listen(channelName:String, fn:Function):void {
  12. if (!channels[channelName]) {
  13. channels[channelName] = new Vector.<Function>();
  14. }
  15. (channels[channelName] as Vector.<Function>).push(fn);
  16. }
  17.  
  18. public static function call(channelName:String):void {
  19. if (!channels[channelName]) {
  20. channels[channelName] = new Vector.<Function>();
  21. }
  22. var v:Vector.<Function> = channels[channelName];
  23. for each (var fn:Function in v) {
  24. fn();
  25. }
  26. }
  27.  
  28. public static function clear(channelName:String):void {
  29. if (channels[channelName]) {
  30. delete channels[channelName];
  31. }
  32. }
  33.  
  34.  
  35. private static var _listiners:Dictionary = new Dictionary();
  36. public static function updateObject(o:Object):void {
  37. for (var fn:Function in _listiners) {
  38. if (_listiners[fn] == o) {
  39. fn(o);
  40. }
  41. }
  42. }
  43.  
  44. public static function listenObject(o:Object, fn:Function):void {
  45. _listiners[fn] = o;
  46. }
  47.  
  48. public static function cleanObject(fn:Function):void {
  49. delete _listiners[fn];
  50. }
  51.  
  52. public function AFn() {
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement