Hello San Francisco!

Just completed my relocation from Moscow to San Francisco. Weather is great and people are friendly.

Spark AdvancedDataGrid

I have used the logic from Spark Tree to build AdvancedDataGrid based on Spark DataGrid and it seem to work nice:


View Source

Since AdvancedDataGridcontains a few code and uses a lot of Spark Tree logic I’ve decided to add it to the Spark Tree project in GitHub.com instead of creating a separate library.

Note: you will not see disclosure icons unless you specify corresponding item renderer for some column: <s:GridColumn itemRenderer="com.sparkTree.DefaultTreeADGItemRenderer"/>

Download SparkTree4.5.swc for Flex SDK 4.5 and higher.

Please report bugs in comments or to the GitHub Issue Tracker.

Sorting images by color

Here is a quick example how to sort images by color.

View source

Basically I just sort images by hue of the major image color. The issue is how to get that color. I get some image pixels, clusterize them and take the center of the best cluster.

Android USB driver

If you plan to test the amazing new Flash Builder Android features and can’t install the USB driver for your phone – just install the PdaNet. It will smoothly put the driver in place and you will be able to debug your mobile project on your device.

Pronto 4

I’m happy to present the project I’ve been working on for the last 2 years.


Continue reading “Pronto 4″

FTheme.com launch

FTheme.com is my new library that hopefully will make a small revolution in Flex 4 styling and skinning. New application look can be created in Notepad, loaded at runtime and change everything from application background bitmap fill to the CheckBox-es size.

Hope that you enjoy existing looks (NightSky is my favorite). Looking for forward for your feedback and new exciting looks.

Year summary

It was a good year, thank you for reading this blog – hope it is useful at least sometimes :) Starting from the 20-th August 2010 when this blog was opened:

  • More than 2900 people came and read more than 5000 pages
  • Average time on site for each visitor was more than 2 minutes.
  • 600 visitors came from USA, 585 from Russia and 222 from Ukraine.
  • Most popular posts were Spark Tree and storing icons in external ZIP.
  • 45% were using Firefox, 31% Chrome and 10% Safari.

Here is some personal statistics according to the StatSVN:

  • In this year I’ve committed 277 559 lines of code that is 1 100 lines/day.
  • 45% lines were modifications and 55% were new.

One of my next posts is going to be about the look&feel customization system that we are developing in CommuniGate for Pronto:

It’s super-powerful, lightweight and fully backward-compatible (while runtime Flex styles in SWFs are not).

Spark Tree on GitHub

I’ve just uploaded Spark Tree component to the GitHub so if you’ve got some updates or bug fixes – please send pull requests :) Also the package is changed – now it’s com.sparkTree.

Download SparkTree.swc
Download source code

AMFPHP in convinient and reliable way

Remoting with AMFPHP greatly simplifies the client-server application logic. Now I’m going to simplify it’s usage. No responders, no listeners or clients. Just one call(...) and one callback function:

  1. private function init():void
  2. {
  3.     new Gateway("http://localhost/amfphp/gateway.php");
  4. }
  5.  
  6. private function listButton_clickHandler(event:MouseEvent):void
  7. {
  8.     listButton.enabled = false;
  9.     call("Persons.listPersons", 10, listPersonsCallback);
  10. }
  11.  
  12. private function listPersonsCallback(object:Object, errorText:String):void
  13. {
  14.     listButton.enabled = true;
  15.     listButton.errorString = errorText;
  16.     if (errorText)
  17.         return;
  18.    
  19.     // handle persons from object
  20. }

Here is the Persons.php service:

  1. < ?php
  2. class Persons
  3. {
  4.  
  5.     var $link;
  6.  
  7.     public function __construct()
  8.     {
  9.         $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
  10.         if (!$link)
  11.             throw new Exception("DB connection error" . (PRODUCTION_SERVER|> ? "" : ": " . mysql_error()));
  12.         if (!mysql_select_db(DB_NAME))
  13.             throw new Exception("DB selection error" . (PRODUCTION_SERVER|> ? "" : ": " . mysql_error()));
  14.     }
  15.  
  16.     function listPersons($limit)
  17.     {
  18.         $query = sprintf("SELECT * FROM persons LIMIT %d",
  19.             mysql_real_escape_string($limit));
  20.         $this->_handleResultError($result = mysql_query($query)));
  21.  
  22.         return $result;
  23.     }
  24.    
  25.     // utility function
  26.     function _handleResultError(&$result)
  27.     {
  28.         if (!$result)
  29.             throw new Exception("query error" . (PRODUCTION_SERVER|> ? "" : ": " . mysql_error()));
  30.     }
  31.  
  32. }

Download Gateway.as and call.as

Callback function can have the following signatures depending on the application logic:

  • function():void
  • function(errorText:String):void
  • function(object:Object, errorText:String):void

Flash Builder Buritto – code templates and content assist workaround

Adobe has recently released a preview version of new Flash Builder – Buritto that has many great features including code templates. Here are my ActionScript code templates so far (download templates.xml to import):

  • commitProperties
  • createChildren
  • getterNoChange
  • getterSetterWithEvent
  • measure
  • model
  • noChangeEvent
  • separator
  • separatorSmall
  • setter
  • updateDisplayList

Also there is a weird issue that content assist shows empty dropdown on first Ctrl+Space and then shows separately varibales, properties, methods and etc. assist on each Ctrl+Space. This can be worked around by unchecking all items in Content Assist Cycling preferences panel:


I seemed to have “All” checkbox but now I don’t see it now. If you will see it, check it :)

Thanks, Adobe! :)