Error: Could not resolve <mx:columns> to a component implementation

Error: Could not resolve <mx:columns> to a component implementation

我 运行 在我的 Flash Web 应用程序编译时遇到此错误的问题

Error: Could not resolve <mx:columns> to a component implementation.

这是过去的样子(而且它会编译)

<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml" verticalScrollPolicy="auto">
<mx:AdvancedDataGrid id="myDataGrid" 
            width="100%"
            showHeaders="false" 
            includeInLayout="{myDataGrid.visible}"
            defaultLeafIcon="{null}"
            horizontalGridLines="true"
            verticalGridLines="true"
            horizontalGridLineColor="#E4E4E4"
            verticalGridLineColor="#E4E4E4"
            rowCount="6"
            minHeight="94"
            variableRowHeight="true"
            selectable="false"
            >  

    <mx:columns>
        <mx:AdvancedDataGridColumn  dataField="Property" headerText="Property" backgroundColor="#E5EFF5" width="0.5" wordWrap="true"/>
        <mx:AdvancedDataGridColumn  dataField="Value" headerText="Value" backgroundColor="white" width="0.5" itemRenderer="MyCustomRenderer"/>
        <mx:AdvancedDataGridColumn  dataField="RowIdentifier" visible="false"/>
    </mx:columns> 
</mx:AdvancedDataGrid> 
</mx:Box>

现在我想改成下面这样

//In ActionScript
package widgets
{
import mx.controls.AdvancedDataGrid;

public class CustomAdvancedDataGrid extends AdvancedDataGrid
{
    public function CustomAdvancedDataGrid()
    {
    }

    override protected function measure():void
    {
        super.measure();
        if(this.dataProvider != null && this.dataProvider.length > 0)
        {
            this.measuredHeight = this.measureHeightOfItems(0, dataProvider.length);
        }
    }
}
}


// In Modified mxml to use the subclass
<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml" 
    xmlns:customWidgets="widgets.*"
    verticalScrollPolicy="auto">
<customWidgets:CustomAdvancedDataGrid id="myDataGrid" 
            width="100%"
            showHeaders="false" 
            includeInLayout="{myDataGrid.visible}"
            defaultLeafIcon="{null}"
            horizontalGridLines="true"
            verticalGridLines="true"
            horizontalGridLineColor="#E4E4E4"
            verticalGridLineColor="#E4E4E4"
            rowCount="6"
            minHeight="94"
            variableRowHeight="true"
            selectable="false"
            >  

    <mx:columns>
        <mx:AdvancedDataGridColumn  dataField="Property" headerText="Property" backgroundColor="#E5EFF5" width="0.5" wordWrap="true"/>
        <mx:AdvancedDataGridColumn  dataField="Value" headerText="Value" backgroundColor="white" width="0.5" itemRenderer="MyCustomRenderer"/>
        <mx:AdvancedDataGridColumn  dataField="RowIdentifier" visible="false"/>
    </mx:columns> 
</customWidgets:CustomAdvancedDataGrid> 
</mx:Box>

我已按照另一个 Whosebug link 中的建议将 mx.swc 添加到 Flex 编译器路径,但这没有帮助。

感谢任何帮助。

由于您的 AdvancedDataGrid 子类位于不同的命名空间中,columns 成员需要位于相同的命名空间中:

<customWidgets:CustomAdvancedDataGrid ...>
    <customWidgets:columns>
        <mx:AdvancedDataGridColumn ...>
    </customWidgets:columns>
</customWidgets:CustomAdvanceDataGrid>