Flash 8 Documentation |
|||
| Components Language Reference > RectBorder class > Creating a custom RectBorder implementation | |||
The RectBorder class is used as a border skin in most ActionScript 2.0 components. The default implementations in both the Halo and Sample themes use ActionScript to draw the border. A custom implementation must use ActionScript to register itself as the RectBorder implementation and provide sizing functionality, but can use either ActionScript or graphic elements to represent the visuals.
Each RectBorder implementation must comply with the following requirements:
offset property value or implement the getBorderMetrics method to return sizing information.drawBorder() method to draw or size the border.The implementation can reuse standard borders for special borders, as the Sample theme does.
All components look to a central location for a reference to the RectBorder class in use for the document, _global.styles.rectBorderClass. You cannot specify that an individual component should use a different RectBorder implementation. To customize RectBorder for a component, you must rely on the borderStyle style property.
The RectBorder implementations provided by the Halo theme and the Sample theme use the ActionScript drawing API to draw the borders for different styles. The following example demonstrates how to create a custom RectBorder implementation that uses graphic symbols for its display.
For this example, use myTheme.
import mx.core.ext.UIObjectExtensions;
class mx.skins.myTheme.RectBorder extends mx.skins.RectBorder
{
static var symbolName:String = "RectBorder";
static var symbolOwner:Object = RectBorder;
var className:String = "RectBorder";
#include "../../core/ComponentVersion.as"
// All of these borders have the same size edges, 1 pixel.
var offset:Number = 4;
function init(Void):Void
{
super.init();
}
function drawBorder(Void):Void
{
// The graphics are on the symbol's timeline,
// so all you need to do here is size the border.
_width = __width;
_height = __height;
}
// Register the class as the RectBorder for all components to use.
static function classConstruct():Boolean
{
UIObjectExtensions.Extensions();
_global.styles.rectBorderClass = RectBorder;
_global.skinRegistry["RectBorder"] = true;
return true;
}
static var classConstructed:Boolean = classConstruct();
static var UIObjectExtensionsDependency = UIObjectExtensions;
}
If you're not using the myTheme package, change the class declaration as needed.
RectBorder.The identifier is automatically filled in as RectBorder.
This example uses mx.skins.myTheme.RectBorder.
For example, draw a hairline square with no fill. To make the custom border easy to see, set the line color to bright red.
Your custom drawBorder implementation sets the width and height according to the component requirements.
For example, drag a List, TextArea, and TextInput component to the Stage.
This example creates a very simple border implementation with static color and graphics. It doesn't respond to different borderStyle settings; it always uses the same graphics regardless of borderStyle. For examples of more complete border implementations, review the examples provided for the Halo and Sample themes.
Version 8
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/8/main/00003950.html
Comments
electricspace said on Mar 22, 2006 at 6:08 AM :