Archive for March, 2011

1 million row DataGrid: ZendAMF, Flex data-paging, MySql

Wednesday, March 16th, 2011

Recently saw James Wards’ example of data paging in Flex 4,  and Mihai Corlans ZendAMF/PHP remoting tutorial on his blog.

To further explore the use of the very speedy AMF remoting (which I think we could use on some projects in work), I created a demo app with a Flex 4 DataGrid that displays the top 1 million ranked websites.

I have stored the data on a MySQL database, access it using remote procedure calls via ZendAMF/PHP, and use Flex AsyncListView and James Wards PagedList for data-paging. The demo has variable paging sizes (hit Reset All to clear the grid and reset page size), and a tracker to show the queued and completed remote procedure calls.

Flex ZendAMF DataPaging (View Source enabled)

The website rankings data was downloaded from www.alexa.com

Mutually Exclusive Shared ComboBox – Flex 4

Wednesday, March 16th, 2011

This custom component I developed extends ComboBox, and allows a number of ComboBox based components to be added to the stage (dynamically or statically), and they are all linked via a shared DataProvider.

In essence, the ComboBox components are shared, and selecting an item in one comboBox removes that item as a selectable option in any other ComboBox. Inversely, if a ComboBox is removed, its selected item becomes available to the others again.

Shared ComboBox demo (right click to view source)

  • IoC to inject a class with a static xmlList into the ComboBox components
  • getQualifiedClassName() and getDefinitionByName() to create Class references on the fly
  • Use of weak reference event listeners and custom events
  • Custom Spark Button class and button Skin
  • Forced garbage collection using the following:
/**
* Forces a garbage collection to occur. More reliable
* than System.gc();
*/
private function garbageCollectionHack():void{

   try {
       new LocalConnection().connect('foo');

       new LocalConnection().connect('foo');

     } catch (e:*) {}
}

In you add a change event handler, you can reference the sharedComboBox.ownedItem (this is handy if you passed in objects – in xml form – to your dataProvider)