2008-08-08 87 views
7

有谁知道你会得到如下警告ComboBox的selectedItem属性使用BindingUtils时,为什么呢?任何想法如何解决这个问题?如何摆脱“多的describeType条目”的警告?

的结合仍然正常工作,但它会很高兴摆脱了警告。

warning: multiple describeType entries for 'selectedItem' on type 'mx.controls::ComboBox': 
<accessor name="selectedItem" access="readwrite" type="Object" declaredBy="mx.controls::ComboBase"> 
    <metadata name="Bindable"> 
    <arg key="" value="valueCommit"/> 
    </metadata> 

回答

0

这是代码。这是basicly BindingUtils.bindProperty的副本是建立一个组合框,这样二者组合框和模型更新当两个变化。

public static function bindProperty2(site:Object, prop:String, host:Object, chain:Object, commitOnly:Boolean = false):ChangeWatcher 
{ 
    var cbx:ComboBox = null; 
    if (site is ComboBox) { cbx = ComboBox(site); } 
    if (host is ComboBox) { cbx = ComboBox(host); } 
    var labelField:String = "listID"; 

    var w:ChangeWatcher = ChangeWatcher.watch(host, chain, null, commitOnly); 

    if (w != null) 
    { 
     var func:Function; 

     if (site is ComboBox) 
     { 
      func = function(event:*):void 
      { 
       var dp:ICollectionView = ICollectionView(site.dataProvider); 
       var selItem:Object = null; 

       for (var i:int=0; i<dp.length; i++) 
       { 
        var obj:Object = dp[i]; 
        if (obj.hasOwnProperty(labelField)) 
        { 
         var val:String = String(obj[labelField]); 
         if (val == w.getValue()) 
         { 
          selItem = obj; 
          break; 
         } 
        } 
       } 

       site.selectedItem = selItem; 
      }; 

      w.setHandler(func); 
      func(null); 
     } 
     else 
     { 
      func = function(event:*):void 
      { 
       var value:Object = w.getValue(); 
       if (value == null) 
       { 
        site[prop] = null; 
       } 
       else 
       { 
        site[prop] = String(w.getValue()[labelField]); 
       } 
      }; 
      w.setHandler(func); 
      func(null); 
     } 
    } 

    return w; 
} 
+0

这似乎不会成为一个问题的答案 – rfunduk 2009-06-15 16:55:42

1

重写相关属性并声明它最终会更好。