如何摆脱“多个describeType条目”警告?

时间:2008-08-08 14:18:10

标签: flex actionscript-3 air

有没有人知道为什么在ComboBox的selectedItem属性上使用BindingUtils时会出现以下警告?有任何想法如何解决这个问题?

绑定仍然可以正常工作,但摆脱警告会很好。

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>

2 个答案:

答案 0 :(得分:1)

最好覆盖有问题的属性并将其声明为最终属性。

答案 1 :(得分:0)

这是代码。它基本上是为ComboBox设置的Binding Utils.bind属性的副本,这样当两者中的任何一个发生更改时,组合框和模型都会更新。

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;
}