Color Name Class (SVG 1.0 - X11 and VGA)

| | Comments (0)

One small thing I've always found a bit handy with CSS in XHTML is the ability to type familiar names for colors rather than the hex value.

Unfortunately, Flash's StyleSheet does not support color names at all and Flex's StyleManager only supports the 16 basic VGA color names.

I decided to write a class that adds static properties for all of the color names defined by SVG 1.0 (The colors in SVG 1.0 include the X11 colors with the addition of gray/grey variants. X11 includes the 16 basic VGA, or HTML4, colors as well). This class also adds two static convenience methods for returning a Color* object by passing in the color name or hexadecimal color value.

*The name that made the most sense for this class was Color and since the Flash Color class has been removed with AS3, there was no reason not to use it.

While this class does not extend the CSS parsing capabilities of Flash, it could be used by an advanced StyleSheet class that overwrites the parseCSS method using this class as a lookup.
This class could also be extended to add (or overwrite) color values specific to a project you are working on. By setting up static properties for a project color set, the project team could be assured that the colors being used are consistent between team members.

Description:
The Color class defines the names and hexadecimal values of the colors defined in SVG 1.0.

Documentation:
Color Class Documentation

Download Color Class

Reposition ScrollBars in Flex Components

| | Comments (1)

I was under the assumption that someone had already figured this out, but I searched forever last night trying to find out how to move the VScrollBar to the left-hand side of a TextArea component and came up with nothing. (If I've overlooked something, forgive me... but at least this will help others when trying to find the answer).

After digging through the source code for a bit, I came up with the solution.
Now this has only been tested with the TextArea component and vertical scrollbar, but should work with any component that extends ScrollControlBase and should work with the horizontal scrollbar as well.
The other thing to keep in mind is that this might (and probably does) mess up the size calculations of the component... I didn't look into that.

So without further ado, create a class that extends the TextArea component and override the protected updateDisplayList method like so:

protected override function updateDisplayList( unscaledWidth:Number, unscaledHeight:Number ):void
{
 	super.updateDisplayList( unscaledWidth, unscaledHeight );
 	
 	if( verticalScrollBar && verticalScrollBar.visible )
 	{
  		verticalScrollBar.x = -verticalScrollBar.width;
  	}
}

Dead simple.

This sets the vertical scrollbar of the TextArea component to the far left side of the component. You can change the verticalScrollBar.x value to whatever you like to position the scrollbar elsewhere. Also, you should be able to do the same check for horizontalScrollBar and change its position within the if statement to move it. Like I said, I haven't checked that out, but it should work.

Let me know.

June 2008

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          

Categories

Archives