2008-08-08 6 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

다음은 코드입니다. 기본적으로 BindingUtils.bindProperty의 복사본으로 ComboBox를 설정하므로 두 가지 중 하나가 변경되면 콤보 상자와 모델이 모두 업데이트됩니다.

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

1

문제의 속성을 무시하고 최종 선언하는 것이 좋습니다.