April 17, 2008
Flex SDK coding conventions and best practices
February 17, 2007
Text control with truncateToFit property support
As you probably know, Label control supports truncateToFit property, while Text doesn't. Even if you explicitly set it to true in your particular Text instance, nothing happens. I have created TruncatedText class that acts the similar way as Label does. If a TruncatedText instance is sized to be smaller than its text, the text is truncated with "...":
January 10, 2007
How to prevent pop-up blocking in Firefox
Using navigateToURL() method causes pop-up blocking feature activation in Firefox since Flash is a plug-in:
Use window.open() JavaScript method instead. I have created URLUtil class with openWindow() static method to make it easier:
Now my blog could be opened in a new browser window this way:
January 9, 2007
Left aligned label in FormItem
FormItem class doesn't have any styles or properties to control corresponding label alignment. Right alignment is applied by default and it's good idea to keep it "as is", because some usability researches say it's more friendly for user. Though if you want to make your FormItem label left aligned, use ExtendedFormItem class instead of regular FormItem:
ExtendedFormItem label is left aligned by default, but you can set labelAlign style to "right" if necessary.
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.