Entries for month: April 2009

Flex Error 1009 when clicking on DataGrid Header to sort.

Encountered this error while working with a datagrid and using the itemClick property to select and item from the datagrid.

 

The solution is to use the "change" property and pass a ListEvent to your handler function. I was using the click property on the datagrid and pass a MouseEvent to the handler function. The change function does not get fired when the header is clicked and now error 1009. See before and after code below.

 

BEFORE CODE

<mx:Script>
    <![CDATA[

    private function clickHandler(event:MouseEvent):void
    {
        trace(Click Handler;);
    }   

]]>

</mx:Script>

<mx:DataGrid width="100%" height="100%"
    dataProvider="{myAC}"
    click="clickHandler(event)">
    <mx:columns>
        <mx:DataGridColumn headerText="Title" dataField="title"/>
    </mx:columns>
</mx:DataGrid>

 

AFTER CODE

<mx:Script>
    <![CDATA[

    private function changeHandler(event:ListEvent):void
    {
        trace('Change Handler;);
    }

]]>

</mx:Script>

<mx:DataGrid width="100%" height="100%"
    dataProvider="{myAC}"
    change="changeHandler(event)">
    <mx:columns>
        <mx:DataGridColumn headerText="Title" dataField="title"/>
    </mx:columns>
</mx:DataGrid>

 

Select Statement using LIKE with SQL Lite in an AIR Application

Working on an AIR project with the local SQLLite database I created a search interface that required a LIKE operator for my SQL statement. Normally, it's not a big deal. I would put some single quotes with percent symbols as wild card around my search parameter.

 

It took a bit of searching to find out the correct syntax with SQL Lite for the AIR application. See below.

 

SELECT *
FROM tblFruit
WHERE (tblFruit.label) LIKE '%' || @SEARCHTEXT || '%'

 

I've created a project file which demonstrates the above code.

 

Download flex project here.

 

Aren't sure how to import this into your flex workspace? I've written a post about that as well.

 

How to bring an existing Flex / AIR project into your FlexBuilder workspace.

Learning Flex can be a challenge and I've found looking at sample code that demonstrates a technique very helpful. You've found a good example, but how to move it into your work space.

 

Here are the steps.

 

  1. Download the flex project (i.e. samplecode.zip).
  2. Open FlexBuilder.
  3. Select File > Import > Flex Project.
  4. Next to "archive file" click the browse button and locate the zipped flex project on your hard drive.
  5. You may want to change the Project Location. For example to your web root if you are running server code. Of course this may be unnecessary for sample code you are learning from.
  6. Click the Finish button.

 

Now you can open and run the sample code, pick it apart and take that next step as a Flex developer.

 

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds