home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Darbas / kidoz_v1.air / kidoz.swf / scripts / mx / rpc / xml / ContentProxy.as < prev    next >
Encoding:
Text File  |  2009-05-06  |  4.8 KB  |  192 lines

  1. package mx.rpc.xml
  2. {
  3.    import flash.utils.Proxy;
  4.    import flash.utils.flash_proxy;
  5.    import flash.utils.getQualifiedClassName;
  6.    import mx.utils.ObjectProxy;
  7.    import mx.utils.ObjectUtil;
  8.    import mx.utils.object_proxy;
  9.    
  10.    use namespace flash_proxy;
  11.    use namespace object_proxy;
  12.    
  13.    public dynamic class ContentProxy extends Proxy
  14.    {
  15.       private var _isSimple:Boolean = true;
  16.       
  17.       private var _content:*;
  18.       
  19.       private var _propertyList:Array;
  20.       
  21.       private var _makeObjectsBindable:Boolean;
  22.       
  23.       public function ContentProxy(param1:* = undefined, param2:Boolean = false, param3:Boolean = true)
  24.       {
  25.          super();
  26.          object_proxy::content = param1;
  27.          object_proxy::makeObjectsBindable = param2;
  28.          object_proxy::isSimple = param3;
  29.       }
  30.       
  31.       override flash_proxy function deleteProperty(param1:*) : Boolean
  32.       {
  33.          var _loc2_:* = false;
  34.          var _loc3_:Object = null;
  35.          if(!_isSimple && _content != null)
  36.          {
  37.             _loc3_ = _content[param1];
  38.             _loc2_ = delete _content[param1];
  39.          }
  40.          return _loc2_;
  41.       }
  42.       
  43.       object_proxy function set makeObjectsBindable(param1:Boolean) : void
  44.       {
  45.          _makeObjectsBindable = param1;
  46.          if(param1 && !_isSimple && !(_content is ObjectProxy))
  47.          {
  48.             _content = new ObjectProxy(_content);
  49.          }
  50.       }
  51.       
  52.       override flash_proxy function nextValue(param1:int) : *
  53.       {
  54.          if(!_isSimple && _content != null)
  55.          {
  56.             return _content[_propertyList[param1 - 1]];
  57.          }
  58.          return undefined;
  59.       }
  60.       
  61.       override flash_proxy function getProperty(param1:*) : *
  62.       {
  63.          if(_content != null)
  64.          {
  65.             return _content[param1];
  66.          }
  67.          return undefined;
  68.       }
  69.       
  70.       override flash_proxy function hasProperty(param1:*) : Boolean
  71.       {
  72.          var _loc2_:* = false;
  73.          if(_content != null)
  74.          {
  75.             _loc2_ = param1 in _content;
  76.          }
  77.          return _loc2_;
  78.       }
  79.       
  80.       object_proxy function setupPropertyList() : void
  81.       {
  82.          var _loc1_:String = null;
  83.          if(getQualifiedClassName(_content) == "Object")
  84.          {
  85.             _propertyList = [];
  86.             for(_loc1_ in _content)
  87.             {
  88.                _propertyList.push(_loc1_);
  89.             }
  90.          }
  91.          else
  92.          {
  93.             _propertyList = ObjectUtil.getClassInfo(_content,null,{
  94.                "includeReadOnly":false,
  95.                "uris":["*"]
  96.             }).properties;
  97.          }
  98.       }
  99.       
  100.       object_proxy function set content(param1:*) : void
  101.       {
  102.          if(param1 is ContentProxy)
  103.          {
  104.             param1 = ContentProxy(param1).object_proxy::content;
  105.          }
  106.          _content = param1;
  107.       }
  108.       
  109.       override flash_proxy function nextNameIndex(param1:int) : int
  110.       {
  111.          if(param1 == 0)
  112.          {
  113.             object_proxy::setupPropertyList();
  114.          }
  115.          if(param1 < _propertyList.length)
  116.          {
  117.             return param1 + 1;
  118.          }
  119.          return 0;
  120.       }
  121.       
  122.       override flash_proxy function setProperty(param1:*, param2:*) : void
  123.       {
  124.          var _loc3_:* = undefined;
  125.          if(_isSimple)
  126.          {
  127.             _loc3_ = _content;
  128.             if(_loc3_ !== param2)
  129.             {
  130.                _content = param2;
  131.             }
  132.          }
  133.          else
  134.          {
  135.             if(_content == null)
  136.             {
  137.                _content = object_proxy::createObject();
  138.             }
  139.             _loc3_ = _content[param1];
  140.             if(_loc3_ !== param2)
  141.             {
  142.                _content[param1] = param2;
  143.             }
  144.          }
  145.       }
  146.       
  147.       object_proxy function set isSimple(param1:Boolean) : void
  148.       {
  149.          _isSimple = param1;
  150.       }
  151.       
  152.       object_proxy function get content() : *
  153.       {
  154.          return _content;
  155.       }
  156.       
  157.       override flash_proxy function callProperty(param1:*, ... rest) : *
  158.       {
  159.          if(_content != null)
  160.          {
  161.             return _content[param1].apply(_content,rest);
  162.          }
  163.          return undefined;
  164.       }
  165.       
  166.       object_proxy function createObject() : *
  167.       {
  168.          if(object_proxy::makeObjectsBindable)
  169.          {
  170.             return new ObjectProxy();
  171.          }
  172.          return {};
  173.       }
  174.       
  175.       object_proxy function get isSimple() : Boolean
  176.       {
  177.          return _isSimple;
  178.       }
  179.       
  180.       object_proxy function get makeObjectsBindable() : Boolean
  181.       {
  182.          return _makeObjectsBindable;
  183.       }
  184.       
  185.       override flash_proxy function nextName(param1:int) : String
  186.       {
  187.          return _propertyList[param1 - 1];
  188.       }
  189.    }
  190. }
  191.  
  192.