Subscribe to RSS
get email updates
home | about | pixDif AIR app | video tutorials
polyGeek.com

place your ad here

Web Premium



Get Qwest High Speed Internet



Make the Label component more like a button

October 16th, 2008 . by polygeek

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.

If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts

7 Responses to “Make the Label component more like a button”


comment number 1 by: Jason

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.

comment number 2 by: Jason

Hmmm, that pretty much destroyed the code I just entered – how can I go about formatting code in the comments?

comment number 3 by: polygeek

@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.

comment number 4 by: Jason

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.

comment number 5 by: polygeek

@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.

comment number 6 by: TroyWorks

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


[...] Then I got involved in the discussion at polygeek when I was trying to make text in Flex look like a normal HTML link. [...]

   Welcome back (Change)

Leave a Reply

comment feed RSS   subscribe to this comment thread

Recent Posts

   



polyGeek.com

© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
M2 Websites
Local Directory for Los Angeles, CA

Better Tag Cloud