One of the things lacking in Flex 2.0 is the ability to easily draw primitive objects. Whether it be for style enabled itemrenderers, programmatic skins, or a style enabled rating component like the one included with this explorer as a sample. I’ve abstracted the primitive algorithms into handy UIComponents. Direct access to the static drawing utility class is available.

PrimitiveExplorer

All UIComponent derivatives are completely style enabled including gradient fills, gradient borders, background colors, line thickness etc.. Each primitive UIComponent is ready for itemrenderer, itemeditor, or standalone usage.

Sample code for direct class, mxml, and css use is generated automatically. Future versions will improve upon this. Specifically removing un required tags.

Base set includes Star, Burst, Reverse Burst, Polygon, Gear, Wedge, and Arc. Allot of different shapes can be created with this base set (to many to mention here).

Have a look at the PrimitiveStyles.as styles include file for a list of supported styles 32 in all, and the sample rating component.

The rating component includes the following styles:
horizontalGap
paddingLeft
paddingTop

The RatingItem has support for a limited set of fill type styles.

I fully intend on continuing the development of this tool. Adding more primitive algorithms, styles, and other ideas I have.

Suggestions for future improvements are most welcome including samples, ideas, bug’s found etc..

Credits:

The DrawUtils.as static class is based on primitive algorithms originally published here by Ric Ewing and here extended to Flash 8 by Kevin Williams. I then ported them to Flex 2. This class has a due credit mention in it that should remain.

The explorer application code is based off of the Style Explorer and components provided by Adobe Consulting. I did make some changes though. In particular, the color picker wheel rollover actions (it was bugging the heck out of me, sorry Adobe). I removed the mini list that closes as there was really no need for it in this explorer. Lastly the code and sandbox are positioned differently.

You’ll need Flash Player 9 to view it and Flex 2.0.1 to use it (I have not tested this with Flex 2.0).

A multitude of components and classes to serve a multitude of purposes. Hopefully other Flex developers see the same value as I do in utilities like this one.

Give the components a second to load when you click in the tree there are quite a few properties for modification.

Enjoy.

Flex 2.0 Primitive Explorer (rigth click for source).

Jason Hawryluk

27 Responses to “Flex 2.0 Primitive Explorer”

  1. greg h Says:

    Wow!! Bravo!!

    This is FANTASTIC!!!

    Thank you Jason, and Kevin and Ric.

    I learn most quickly when I can visualize the result and have access to the code which I can rip apart. What you have packaged up here is perfect for helping me dig deeper into the Drawing API and the AS3 flash.display.Graphics Class.

    And just as helpful for Flash AS3 developers as for Flex 2 developers.

    Your Flex 2.0 Primitive Explorer will be tremendously useful for others for years to come.

    Thanks again :-)

    g

  2. Shigeru Says:

    So interesting!!

  3. Arul Says:

    Nice Work! Thanks for the efforts

    I got the following error randomly clicking through the tree. I could not reproduce the issue again.

    RangeError: Error #2006: The supplied index is out of bounds.
    at flash.display::DisplayObjectContainer/getChildAt()
    at mx.core::Container/getChildAt()
    at mx.containers::ViewStack/get selectedChild()
    at mx.containers::ViewStack/::commitSelectedIndex()
    at mx.containers::ViewStack/mx.containers:ViewStack::commitProperties()
    at mx.core::UIComponent/validateProperties()
    at mx.managers::LayoutManager/::validateProperties()
    at mx.managers::LayoutManager/::doPhasedInstantiation()
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/::callLaterDispatcher2()

  4. flexibleexperiments Says:

    Arul,

    Thanks I’ll have a look to see if I can reproduce it. Hopefully I’ll have a fix for the next version.

    Greg,

    Thanks for the thoughtful comment :)

    -jason

  5. Rick Says:

    Very well done! This is extremely useful, thanks for putting the time together to get this going in AS3!

  6. ScaleNine Blog » Blog Archive » Flex 2 Primitive Explorer Says:

    [...] Info: http://flexibleexperiments.wordpress.com/2007/03/14/flex-20-primitive-explorer/ [...]

  7. Juan Says:

    This is great! This is going to help me big time as I get more involved developing programmatic skins.

    Thanks!

  8. Flex geometric primitives « The Algorithmist Says:

    [...] Check it out here. [...]

  9. Joel Says:

    ha! This is awesome. Thank you very much for sharing.

  10. Stefan Schmalhaus Says:

    Great tool! Thanks for sharing!

  11. Flex 2.0.1 Rating Component « Flexible Experiments Says:

    [...] shown as a sample in the Primitive Explorer I thought I’d break it out of that and into a post of it’s own. Mostly because as one could [...]

  12. Как вставить swf файл в flex приложение « OM DESIGN Says:

    [...] Flex 2.0 Primitive Explorer Jason Hawryluk: Flexibleexperiments.wordpress.com [...]

  13. ScaleNine Blog » Blog Archive » Enter Degrafa: A Flex Graphics Framework Says:

    [...] Hawryluk, the creator of the Flex 2 Primitive Explorer, and I are in the process of creating a Declarative Graphics Framework for Flex. We’re [...]

  14. bilgisayar Says:

    thank you

  15. yemek tarifi Says:

    Thanks

  16. Josh Says:

    Nice article. I am learning to program with UIComponents and these kind of articles really help!

  17. embed Says:

    Very cool, thanks. Flex continues to get better

  18. Kevin Says:

    Thanks for these classes. I am wondering if there is an easy way to extend the Poloygon class so that one can draw rectangles width non-matching widths & heights. Thanks for any thoughts on this. I am new to using the Drawing classes in actionscipt.

  19. Flexible Experiments » Blog Archive » Flex 2.0.1 Rating Component Says:

    [...] shown as a sample in the Primitive Explorer I thought I’d break it out of that and into a post of it’s own. Mostly because as one could [...]

  20. Billy Says:

    Great job well done! This is very useful, thanks for putting this online.

    Thnx again

    Billy

  21. flexibleexperiments Says:

    Thanks for the heads up Devnets. It should be working fine now I’ve changed all the urls to point to a new home for this blog that is in the process of being ready.

    Jason

  22. Vincent from the World of Office Tips & Tricks Says:

    Just as earlier, thanks for sharing this!!

    Cheers Jason

    Vincent

  23. Postman Says:

    Very well done! This is extremely useful, thanks for putting the time together.

  24. Origins of a Graphics Framework Says:

    [...] six months after I started ScaleNine I picked up on a blog post by Jason Hawryluk about a “Primitive Explorer” he had created that allows for programmatic drawing of shapes via set parameters. My initial [...]

  25. FlexInflux » Blog Archive » The Flex Style Explorer is a Proud Papa Says:

    [...] 2.0 Primitive Explorer Jason Hawryluk: Flexibleexperiments.wordpress.com Jason starts with the Style Explorer UI, and creates a great application for exploring and [...]

  26. voyance Says:

    Thanks! Great blog!

  27. simplebits.org » Flex Explorers Says:

    [...] Flex 2 Primitive Explorer by Jason Hawryluk, [...]

Leave a Reply