I’ve recently had to parse dates and it turned out that Flex is not very good at it. According to specs, Date.parse() only handle following formats:

MM/DD/YYYY HH:MM:SS TZD
HH:MM:SS TZD Day Mon/DD/YYYY
Mon DD YYYY HH:MM:SS TZD
Day Mon DD HH:MM:SS TZD YYYY
Day DD Mon HH:MM:SS TZD YYYY
Mon/DD/YYYY HH:MM:SS TZD
YYYY/MM/DD HH:MM:SS TZD

Which is fine as long as you live in United States. Not all of us do so I needed to look further. There’s parseDateString method on mx.formatters.DateFormatter but it too does not provide required functionality.

So here is my implementation of date parser. It accepts specified format string and tries to parse given data accordingly. You can use D, M and Y to define this format string and any other character in it will be treated as separator and matched directly. You can refer to unit test provided together with source for usage examples. Please note that set of supported features matches my requirements and you can probably find more complete and feature rich solutions out there.

Advertisements

I’ve been recently working on a component that contained rotated label in it and I discovered that using width and height attributes (MXML) in such case might result in unexpected behaviour.

The problem occurs when you start using absolute values for these properties. If for example you set height to be 100% then actual height of the component will be influenced. However if you set height to be 500, width of the component will be changed instead.

It turns out, that percent size (which is calculated relative to parent and post-transform) would take component’s rotation into account while explicit size is calculated pre-transform (which is a change in Flex 4). While it is all working according to specification trying to use “proxy setters” like width/height might cause some confusion.

You can use this little app to try it.

Update:
Because the server where I was hosting the file was shut down, I created a gist on github.com. You can access it here.

I am using SourceMate with latest prerelase build of Adobe Flash Builder. It still has some issues but otherwise it’s quite cool. It adds features that most Java developers can expect in either IDE they choose. Personally I like refactoring features, implement/override and code assist for metadata the most. Since we extensively use Parsley in our projects, I thought it would be useful to add it’s metadata tags to SourceMate configuration. If you find any mistakes please let me know.

Follow these instructions to make it work:

  1. Download this file and unpack it.
  2. Run Flash Builder, choose Window > Preferences > SourceMate > Metadata and click “Import…” button.
  3. Choose downloaded XML file
  4. Click “Open”. You’re done!

I can’t upload small XML/ZIP, not even paid upgrades allow that. How uncool is that, WordPress?

Big thanks for Espen for hosting that file for me.

Anyway, I hope that helps!

You may encounter some problems with code autocompletion when switching to one of the latest builds of Adobe Flex SDK, especially if you are using Flash Builder Beta 2 and not one of the latest prerelease builds. Flash Builder will be unable to complete class names and add imports from flash.* package. This is because Adobe is getting ready to include playerglobal.swc for version 10.1 of Flash Player.

To make autocompletion work again, you need to:

  1. Rename folder <sdk install dir>/frameworks/libs/player/10.0 to 10
  2. Remove all occurences of “.{targetPlayerMinorVersion}” from flex-config.xml file located in <sdk install dir>/frameworks.
  3. If SDK you are currently modifying is your current one – restart Flash Builder. If not, you may just switch to it without restarting.

Hope that helps!