Wednesday, May 9, 2007

Do you count months from 0 to 11 ???

Just to let you know that for some strange reason Flex dates are a bit 'unusual' (at least to .NET developers like me). When checking the 'month' property of a date it's 1 less than the actual month. Why? Flex assigns 0 to January, 1 to February, 2 to March, ... Easy to get around but rather 'silly', no?

Another unusual thingie is the fact that you need to use the 'date' (!) property in order to get the number of the day in the month (and in this case it is NOT 0-based...).

I assume it's to trick people when doing the brand new Flex2 certification exam :)

Monday, May 7, 2007

Dragging and dropping but what about the Z-INDEX ?

I don't know whether you know but dragging components around the screen is sooo easy in Flex. The code below works within an MXML component. If you want it to work in an MXML application then you should replace 'this' by the actual component name.

mouseDown="this.startDrag(); " mouseUp=" this.stopDrag();"

Question is: how to make the component being dragged the top component (make it appear above all other components) ? After some searching I found the following solution:

mouseDown="this.parent.setChildIndex(this,this.parent.numChildren-1); this.startDrag(); " mouseUp=" this.stopDrag();"