Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by soul on 22.01.15.
- */
- package agnidea.utils {
- import flash.utils.Dictionary;
- import mvcexpress.core.messenger.Messenger;
- public class AFn {
- private static var channels:Dictionary = new Dictionary();
- public static function listen(channelName:String, fn:Function):void {
- if (!channels[channelName]) {
- channels[channelName] = new Vector.<Function>();
- }
- (channels[channelName] as Vector.<Function>).push(fn);
- }
- public static function call(channelName:String):void {
- if (!channels[channelName]) {
- channels[channelName] = new Vector.<Function>();
- }
- var v:Vector.<Function> = channels[channelName];
- for each (var fn:Function in v) {
- fn();
- }
- }
- public static function clear(channelName:String):void {
- if (channels[channelName]) {
- delete channels[channelName];
- }
- }
- private static var _listiners:Dictionary = new Dictionary();
- public static function updateObject(o:Object):void {
- for (var fn:Function in _listiners) {
- if (_listiners[fn] == o) {
- fn(o);
- }
- }
- }
- public static function listenObject(o:Object, fn:Function):void {
- _listiners[fn] = o;
- }
- public static function cleanObject(fn:Function):void {
- delete _listiners[fn];
- }
- public function AFn() {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement