home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2012 April / ME_04_2012.iso / Video-Tutorial / iPhoto / media / player.swf / scripts / mx / binding / BindabilityInfo.as next >
Encoding:
Text File  |  2011-11-11  |  4.1 KB  |  122 lines

  1. package mx.binding
  2. {
  3.    import mx.core.mx_internal;
  4.    import mx.events.PropertyChangeEvent;
  5.    
  6.    use namespace mx_internal;
  7.    
  8.    public class BindabilityInfo
  9.    {
  10.       mx_internal static const VERSION:String = "4.5.0.20967";
  11.       
  12.       public static const BINDABLE:String = "Bindable";
  13.       
  14.       public static const MANAGED:String = "Managed";
  15.       
  16.       public static const CHANGE_EVENT:String = "ChangeEvent";
  17.       
  18.       public static const NON_COMMITTING_CHANGE_EVENT:String = "NonCommittingChangeEvent";
  19.       
  20.       public static const ACCESSOR:String = "accessor";
  21.       
  22.       public static const METHOD:String = "method";
  23.       
  24.       private var typeDescription:XML;
  25.       
  26.       private var classChangeEvents:Object;
  27.       
  28.       private var childChangeEvents:Object = {};
  29.       
  30.       public function BindabilityInfo(param1:XML)
  31.       {
  32.          super();
  33.          this.typeDescription = param1;
  34.       }
  35.       
  36.       public function getChangeEvents(param1:String) : Object
  37.       {
  38.          var childDesc:XMLList = null;
  39.          var numChildren:int = 0;
  40.          var childName:String = param1;
  41.          var changeEvents:Object = this.childChangeEvents[childName];
  42.          if(!changeEvents)
  43.          {
  44.             changeEvents = this.copyProps(this.getClassChangeEvents(),{});
  45.             childDesc = this.typeDescription.accessor.(@name == childName) + this.typeDescription.method.(@name == childName);
  46.             numChildren = int(childDesc.length());
  47.             if(numChildren == 0)
  48.             {
  49.                if(!this.typeDescription.@dynamic)
  50.                {
  51.                   trace("warning: no describeType entry for \'" + childName + "\' on non-dynamic type \'" + this.typeDescription.@name + "\'");
  52.                }
  53.             }
  54.             else
  55.             {
  56.                if(numChildren > 1)
  57.                {
  58.                   trace("warning: multiple describeType entries for \'" + childName + "\' on type \'" + this.typeDescription.@name + "\':\n" + childDesc);
  59.                }
  60.                this.addBindabilityEvents(childDesc.metadata,changeEvents);
  61.             }
  62.             this.childChangeEvents[childName] = changeEvents;
  63.          }
  64.          return changeEvents;
  65.       }
  66.       
  67.       private function getClassChangeEvents() : Object
  68.       {
  69.          if(!this.classChangeEvents)
  70.          {
  71.             this.classChangeEvents = {};
  72.             this.addBindabilityEvents(this.typeDescription.metadata,this.classChangeEvents);
  73.             if(this.typeDescription.metadata.(@name == MANAGED).length() > 0)
  74.             {
  75.                this.classChangeEvents[PropertyChangeEvent.PROPERTY_CHANGE] = true;
  76.             }
  77.          }
  78.          return this.classChangeEvents;
  79.       }
  80.       
  81.       private function addBindabilityEvents(param1:XMLList, param2:Object) : void
  82.       {
  83.          var metadata:XMLList = param1;
  84.          var eventListObj:Object = param2;
  85.          this.addChangeEvents(metadata.(@name == BINDABLE),eventListObj,true);
  86.          this.addChangeEvents(metadata.(@name == CHANGE_EVENT),eventListObj,true);
  87.          this.addChangeEvents(metadata.(@name == NON_COMMITTING_CHANGE_EVENT),eventListObj,false);
  88.       }
  89.       
  90.       private function addChangeEvents(param1:XMLList, param2:Object, param3:Boolean) : void
  91.       {
  92.          var _loc4_:XML = null;
  93.          var _loc5_:XMLList = null;
  94.          var _loc6_:String = null;
  95.          for each(_loc4_ in param1)
  96.          {
  97.             _loc5_ = _loc4_.arg;
  98.             if(_loc5_.length() > 0)
  99.             {
  100.                _loc6_ = _loc5_[0].@value;
  101.                param2[_loc6_] = param3;
  102.             }
  103.             else
  104.             {
  105.                trace("warning: unconverted Bindable metadata in class \'" + this.typeDescription.@name + "\'");
  106.             }
  107.          }
  108.       }
  109.       
  110.       private function copyProps(param1:Object, param2:Object) : Object
  111.       {
  112.          var _loc3_:String = null;
  113.          for(_loc3_ in param1)
  114.          {
  115.             param2[_loc3_] = param1[_loc3_];
  116.          }
  117.          return param2;
  118.       }
  119.    }
  120. }
  121.  
  122.