Flex Shapes
We have been having a discussion on primitive shapes in Flex in our 615 Flex discussion group. As of now, if you want shapes (e.g. circles, rectangles, etc) in Flex you have a few options:
1. Make a circle vector image or SWF in Flash, then load it using an <mx:Image /> loader or something similar
2. Draw the circle using ActionScript code in a function, optionally as a component
3. Use the primitive shape classes developed by Jason Hawryluck (see below)
4. Wait till Flex 4 when they introduce the new native shapes classes, which replace option 3 above (e.g. <mx:Circle />, <mx:Rectangle />, etc)
The primitives classes are just custom components that eventually use the drawing API internally, but allow you to instantiate them into your app as MXML tags. If you want, they are focusable just like normal widgets. Adobe is currently set to introduce their own version of these in Flex 4. In the long meantime I use these primitives to easily get what I want. There is even a Primitives Style Explorer that allows you customize a primitive, then copy/paste the MXML formatted tag into your app. Check out this link for the original post about these classes.
Since these components are not part of the Flex SDK, you need to get the the com.Primitives package of source files and place them in to your project. I am not sure if there is a SWC that contains the compiled classes, I just do what the author suggests and right-click the style explorer, then click View Source to get the source classes.
Now for a sample using the gear primitives. My buddy and fellow 615 Flexer Byron will serve nicely as the demo. We will make gears of his brain his and report on his status (which of course are the two things he claims keep him going). Check it out here. Right-click to view source.
1. Make a circle vector image or SWF in Flash, then load it using an <mx:Image /> loader or something similar
2. Draw the circle using ActionScript code in a function, optionally as a component
3. Use the primitive shape classes developed by Jason Hawryluck (see below)
4. Wait till Flex 4 when they introduce the new native shapes classes, which replace option 3 above (e.g. <mx:Circle />, <mx:Rectangle />, etc)
The primitives classes are just custom components that eventually use the drawing API internally, but allow you to instantiate them into your app as MXML tags. If you want, they are focusable just like normal widgets. Adobe is currently set to introduce their own version of these in Flex 4. In the long meantime I use these primitives to easily get what I want. There is even a Primitives Style Explorer that allows you customize a primitive, then copy/paste the MXML formatted tag into your app. Check out this link for the original post about these classes.
Since these components are not part of the Flex SDK, you need to get the the com.Primitives package of source files and place them in to your project. I am not sure if there is a SWC that contains the compiled classes, I just do what the author suggests and right-click the style explorer, then click View Source to get the source classes.
Now for a sample using the gear primitives. My buddy and fellow 615 Flexer Byron will serve nicely as the demo. We will make gears of his brain his and report on his status (which of course are the two things he claims keep him going). Check it out here. Right-click to view source.

Comments