I know its been very quiet here of late, but I’ve been pretty active on our Google Code.
A couple of weeks go someone who’d checked out the source left a post asking what
Rect was for and how it differed from the
Rect found in FXG. I thought it was about time I wrote a post to cover it.
I was building a dashboard component for a client a couple of weeks back, much like the one found on the main BBC homepage, or iGoogle, where you can add/removed and rearrange the position of the items shown. Much like those I wanted to show the user where the new item would be dropped with a rectangle that had a dashed stroke, and I wanted to be able to defined this in my skin, in MXML using a dropIndicator, to keep things nice and readable.
The problem is that Flash doesn’t support different stroke types, just different weights, and Adobe’s implementation of FXG also doesn’t allow for different stroke types. It’s true I could have drawn it with a complex
Path, but then it wouldn’t have scaled correctly.
So I set about getting some primitive classes together where I could specify custom stoke types the result of which are below. You can also specify custom fill types, although I’m not sure they’ll be as useful as we already have
BitmapFill. Using a the
lineBitmapStyle() method for the stroke just didn’t cut it as the
BitmapData needs to change depending on the direction of the stroke.
I’ve covered the primitives that are included in FXG, but the code is by no means complete and still needs some work to support missing drawing methods, and to fully implement some of the methods that are included.
I’ve also added 2 types of stroke,
SolidColorDash (probably the most useful), and
Hatch can also be used in pure AS if required (props to Senocular where the basis for these classes was lifted).
(right click for source).