home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / filler.swf / scripts / mx / binding / BindingManager.as < prev    next >
Text File  |  2008-09-02  |  3KB  |  93 lines

  1. package mx.binding
  2. {
  3.    import mx.core.mx_internal;
  4.    
  5.    use namespace mx_internal;
  6.    
  7.    public class BindingManager
  8.    {
  9.       
  10.       static var debugDestinationStrings:Object = {};
  11.       
  12.       mx_internal static const VERSION:String = "2.0.1.0";
  13.        
  14.       
  15.       public function BindingManager()
  16.       {
  17.          super();
  18.       }
  19.       
  20.       public static function executeBindings(param1:Object, param2:String, param3:Object) : void
  21.       {
  22.          var _loc4_:* = null;
  23.          if(!param2 || param2 == "")
  24.          {
  25.             return;
  26.          }
  27.          if(param1 && param1._bindingsByDestination && param1._bindingsBeginWithWord && param1._bindingsBeginWithWord[getFirstWord(param2)])
  28.          {
  29.             for(_loc4_ in param1._bindingsByDestination)
  30.             {
  31.                if(_loc4_.charAt(0) == param2.charAt(0))
  32.                {
  33.                   if(_loc4_.indexOf(param2 + ".") == 0 || _loc4_.indexOf(param2 + "[") == 0 || _loc4_ == param2)
  34.                   {
  35.                      param1._bindingsByDestination[_loc4_].execute(param3);
  36.                   }
  37.                }
  38.             }
  39.          }
  40.       }
  41.       
  42.       public static function addBinding(param1:Object, param2:String, param3:Binding) : void
  43.       {
  44.          if(!param1._bindingsByDestination)
  45.          {
  46.             param1._bindingsByDestination = {};
  47.             param1._bindingsBeginWithWord = {};
  48.          }
  49.          param1._bindingsByDestination[param2] = param3;
  50.          param1._bindingsBeginWithWord[getFirstWord(param2)] = true;
  51.       }
  52.       
  53.       public static function debugBinding(param1:String) : void
  54.       {
  55.          debugDestinationStrings[param1] = true;
  56.       }
  57.       
  58.       private static function getFirstWord(param1:String) : String
  59.       {
  60.          var _loc2_:int = 0;
  61.          var _loc3_:int = 0;
  62.          var _loc4_:int = 0;
  63.          _loc2_ = param1.indexOf(".");
  64.          _loc3_ = param1.indexOf("[");
  65.          if(_loc2_ == _loc3_)
  66.          {
  67.             return param1;
  68.          }
  69.          if((_loc4_ = Math.min(_loc2_,_loc3_)) == -1)
  70.          {
  71.             _loc4_ = Math.max(_loc2_,_loc3_);
  72.          }
  73.          return param1.substr(0,_loc4_);
  74.       }
  75.       
  76.       public static function getUIComponentWatcherForDestination(param1:Object, param2:String) : int
  77.       {
  78.          var _loc3_:* = null;
  79.          if(param1._bindingsByDestination)
  80.          {
  81.             for(_loc3_ in param1._bindingsByDestination)
  82.             {
  83.                if(_loc3_ == param2 && param1._bindingsByDestination[_loc3_].uiComponentWatcher != -1)
  84.                {
  85.                   return param1._bindingsByDestination[_loc3_].uiComponentWatcher;
  86.                }
  87.             }
  88.          }
  89.          return -1;
  90.       }
  91.    }
  92. }
  93.