如何消除“多个DescribeType条目”警告?

gblwokeq  于 2022-09-21  发布在  Apache
关注(0)|答案(2)|浏览(125)

有人知道为什么在ComboBox的seltedItem属性上使用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>
tyg4sfes

tyg4sfes1#

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

bxfogqkk

bxfogqkk2#

以下是代码。它基本上是为ComboBox设置的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;
}

相关问题