错误:无法将<mx:columns>解析为组件实现

时间:2015-08-07 17:45:48

标签: actionscript-3 flex flex3 itemrenderer advanceddatagrid

我在我的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>

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

感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

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

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