/** * Copyright (c) 2006 Peter Goodman * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php */ // singleton to hold events.. yah yah singletons are bad.. // oh well. They do the job. class FA.event { private static var _i:FA.event; private var fns:Object = { }; private function event() { } public static function getInstance() : FA.event { if(_i == undefined) { _i = new FA.event(); } return _i; } public static function addEvent(o, e:String, fn:Function) : Void { var i:FA.event = FA.event.getInstance(); var t:String = o._name || typeof o; if(i.fns[t] == undefined) { i.fns[t] = { }; } if(i.fns[t][e] == undefined) { i.fns[t][e] = []; } i.fns[t][e].push(fn); } public static function getEvents(obj, e) : Array { var r:Array = []; var i:FA.event = FA.event.getInstance(); var t:String = obj._name || typeof obj; if(i.fns[t][e]) { r = i.fns[t][e]; } return r; } }