Keeping on par with the current suggestions, extending a base class
(probably either Text or Label) and add these styleable properties to
it. This isn't that hard to do, but it does add complexity by moving
things out of the framework, but as long as we keep submitting
enhancement requests for the things we feel we shouldn't have to extend,
then it will get better :-) Here is some code that I hope will help you
get started( P.S. I chose to override Text because I didn't like the
background the LinkButton put around the its label, but you could
probably use this code to extend a Label or LinkButton. At least it
will show you how to accomplish some custom stuff).
package com {
import mx.controls.Text;
import flash.events.Event;
import flash.events.MouseEvent;
[Style(name="mouseOverColor", type="uint", format="Color",
inherit="no")]
public class ClassicLinkButton extends Text {
public var useMouseOverStyles : Boolean = true;
override protected function
initializationComplete():void {
super.initializationComplete();
addEventListener(
MouseEvent.MOUSE_OVER, underline );
addEventListener(
MouseEvent.MOUSE_OUT, underline );
}
override protected function
commitProperties():void {
super.commitProperties();
mouseChildren = false;
buttonMode = true;
}
private function underline( event : Event ) :
void {
if (!useMouseOverStyles)
return;
if (getStyle( "textDecoration" ) ==
"underline") {
//event.currentTarget.setStyle( "textDecoration", "none" );
//In my use case, I
didn't need to default back to the original styles, but you can modify
the code to do that...
clearStyle("textDecoration");
clearStyle("color");
}
else {
setStyle(
"textDecoration", "underline" );
if
(getStyle("mouseOverColor"))
setStyle("color",getStyle("mouseOverColor"));
}
}
}
}
Dustin Mercer
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Ethan Miller
Sent: Thursday, November 30, 2006 2:40 PM
To: [email protected]
Subject: Re: [flexcoders] Re: Styling in Flex is officially ridiculous
Effective for color, but how about text-decoration, border, etc.? It
would be really nice to keep this in the CSS domain.
cheers, ethan
> <mx:Label id="linkTxt" htmlText="<font color="#0000FF"><a
> href='http://mysite.com <http://mysite.com> '>goto mysite</a></font>"
mouseOver="hover
> ()" />
>
> function hover():void{
> linkTxt.htmlText = String(linkTxt.htmlText).replace
> ('0000FF','00FF00');
> }
>
> you get the idea....
>
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , Ethan Miller <[EMAIL PROTECTED]>
wrote:
> >
> > While in general I've been fairly happy with my ability to style
> > flex, one area in which really lacking (and unfortunately for me
> in a
> > key place for my application) is in styling text, especially text
> > contained in an htmlText element.
> >
> > Despite reading the docs 5 times now, I remain unable to style a
> > simple anchor tag (<A HREF="">. "A" as a type selector doesn't work,
> > but neither do a:link, a:hover, or a:active which the docs say
> should
> > work. Why the A tag doesn't simply support styleName as an attribute
> > (or class="" or style="") is a complete mind bender to me. Why
> > htmlText doesn't support <span styleName=""> is equally puzzling.
> >
> > Also, is it just me or are many of the css property names different,
> > eg font-family vs fontFamily, etc. And what about shorthand syntax,
> > eg "border: 1x dotted black."
> >
> > I realize and accept as necessary and good the need to support a
> > limited set of HTML tags but don't understand why standard and
> > rigorous text styling is so out of reach. This in fact would be one
> > of my top wish list items for future releases.
> >
> > Meantime, if anyone has any tips on styling text now, I'm all
> ears =)
> >
> > cheers, ethan
> >
>
>
>