Flex 4 – RichButton

Application – Source

Its funny when you deal with graphic designers, and the hell they tend to put you through to make your application look good… but in the end it always gives me something to write about and keeps me working so its all good…

Flex 4, I’ve heard fixes the MultiLine Button issue fairly easily (I’ve heard) but I ran into the issue where the button not only needed to be multiline but also needed to be different font styles within the text…

The easiest way I could imagine would be to use the htmlText property of the flex 3, so after reading up on flex 4 and the changes to some of the base text classes, I decided to use the RichText component in flex.  That way I can use the new text stuff they added.

Here is my example, and please don’t hesitate to call me stupid… Flex 4 just got released, and I took no time to mess with the beta (busy working) and so now I get to write up on the stuff I encounter.


2 comments on this post.
  1. Ely Greenfield:

    Very nice Axel. A few comments:
    1) your RichButton class should probably be an AS file, not an MXML file. You’re not actually declaring anything in MXML, and probably paying a small overhead for doing it in MXML.
    2) you might want to make richText the default property for your class so you can skip the tag in your sample.
    3) if you want to write a bulletproof spark component, you should read up on the partAdded and partRemoved functions. Technically, parts can come and go at any time if the skin throws them away in individual states. So whenever a part is added, you should push whatever data is necessary into the part (in this case, the content of the RichText labelDisplay part).

  2. admin:

    1. true, thanks.

    2. yeah, i think was trying to do the defaultProperty but ended up running into some sort of issue with it not acting the way i wanted and i was running short of time when i posted. But i did try, lol.

    3. i will definitely check out the partAdded and partRemoved functions…

    thanks for the comment…

    ps… i go to your blog all the time to remember how to do shit…. can’t thank you enough for the samplers and the fisheye and displayShelf… I learned all about the life cycle of components from some slides i found of yours online… great stuff man.


Leave a comment