December 28, 2006

Singleton in ActionScript 3.0

There are some ways to create singleton in ActionScript 3.0, though I prefer public "facade" with static initialization of internal class:

Internal class (it should be in the same package with "facade"):

Usage example:

December 27, 2006

Make the focused child visible!

Probably, one of the most annoying thing about Flex is lack of "browser native" features support. For example, if you have scrollable container it doesn't scroll its content upon Tab button click to make the focused child visible. However, browser do this! I have created easy to use class AutoScrollManager that makes it possible in Flex:

December 12, 2006

truncateToFit() performance problem

Setting very long string to the text property of classes that decorate UITextField (e. g. Label) causes timeout exception. Take a look at the truncateToFit() method in UITextField class. You could find this block there:

It means that actual text is cut char by char until result of its concatenation with truncation indicator fits into the width available or only one char left. When text is very long this looping is almost infinitive. I believe it would work much more faster with division by 2 approach. In this case even 64K text truncation will take only 16 loop cycles.

My 1st post! :)