Search code examples
flashapache-flexdatagridflash-builder

Adobe flex "could not resolve <s:HBox> to a component implementation" error


I want to load a datagrid to display the query results by web service.

But I get the "could not resolve to a component implementation" error and cannot proceed.

My code is as follows:

<s:HBox height="95%" width="95%" horizontalCenter="0" verticalCenter="0">
            <s:DataGrid id="datagrid" width="645" height="100%"    selectionChange="selectionChangeHandler(event)">
                <s:columns>
                    <s:DataGridColumn headerText="User Name" dataField="userName"/>
                    <s:DataGridColumn headerText="User Email" dataField="userEmail"/>
                    <s:DataGridColumn headerText="Contact No" dataField="contactNo"/>
                </s:columns>
            </s:DataGrid>
        </s:HBox>

If I change spark to mx, then I get another error:

Could not resolve attribute 'selectionChange' for component type mx.controls.Datagrid

What is the corresponding attribute of 'selectionChange' in mx?

How can I solve the problem? I am using Adobe flash builder 4.6.


Solution

  • You have to use HGroup instead of HBox, this component doesn't exists in spark package. Try this:

    <s:HGroup height="95%" width="95%" horizontalCenter="0" verticalCenter="0">
       <s:DataGrid id="datagrid" width="645" height="100%"    selectionChange="selectionChangeHandler(event)">
           <s:columns>
               <s:ArrayList>
                    <s:GridColumn dataField="name" headerText="Name"/>
                    <s:GridColumn dataField="phone" headerText="Phone"/>
                    <s:GridColumn dataField="email" headerText="Email"/>
                </s:ArrayList>
           </s:columns>
        </s:DataGrid>
    </s:HGroup>