I don’t know about you but I find myself using the Label component fairly often to make something like a regular old HTML link. But it really wasn’t meant to do that.
| view source |
First, you can put htmlText in the Lable TextField but you can’t actually type HTML code in the htmlText MXML attribute. So you have to work around that. And, you have to specify:
buttonMode="true"
mouseChildren="false"
useHandCursor="true"
Gee, it’s a frakking link. I’d like it to behave like one when the user mouses over it.
Plus, if you want said link to actually navigate to another html page you have to do all that URLRequest and navigateToURL stuff.
So, I extended the Label component and tossed in all this stuff so that it’s so easy even a Republican nominee for vice president could do it. Well, maybe not that easy. But you get the point. :-)
As an example, to make the middle link above all you need to do is write this MXML code:
<extenders:LableBtn
linkText="Simeon Says ( opens in new window )"
window="_new"
linkURL="http://blog.simb.net/" />
See, told you it was easy.




I was trying to do something very similar in Flex yesterday as well. Being a bit of a noob to it, I wasn’t sure if there was an easier way to get a list of HTML links working. I used the following code:
<![CDATA[RegisterAdmin RegisterFind AttendeeActivate Event]]>
That coupled with some styling gets the list of links looking how they should. Haven’t coupled in any events yet with the links, so that may bring me unstuck.
Hmmm, that pretty much destroyed the code I just entered – how can I go about formatting code in the comments?
@Jason, Good question. I’ll look into a WordPress plugin that might allow for code in the comments. Or maybe I can just change the style to use a mono-spaced font.
Anyway, I’ll email you and see if I can help.
You might like to check out this post http://www.themelab.com/2008/06/15/dipslaying-code-in-wordpress-posts/ to allow code parsing in the comments.
I didn’t have a question so much as an alternative to what you did. I was using a TextArea component then within that a htmlText component to display the links. Just used the CDATA tag to enclose all the html links and then applied a stylesheet to the TextArea component with a and a:hover styles.
@Jason, thanks for the link. I switched the font here in the comments to mono-space and that allowed me to enter some HTML code. I’ll look at the plugins they suggest to improve it.
You played with TextEvent? It’s nifty for doing similar things with plain old TextFields.
http://troyworks.com/blog/2008/03/14/flash-textfield-actionscript-hyperlink-in-as30/
TroyWorkss last blog post..Flash: Embedding Fonts via the Font Symbol