MX. Skins. programmaticskin is the base class of the appearance element. They draw themselves through programming.
The following describes the class by implementing a custom tooltip.
Tooltipborderskin.
Package skins
{
Import flash. display. graphics;
Import flash. Geom. Point;
Import MX. Skins. programmaticskin;
Import flash. Filters. bitmapfilter;
Import flash. Filters. bitmapfilterquality;
Import flash. Filters. dropshadowfilter;
Public class tooltipborderskin extends programmaticskin
{
Public Function tooltipborderskin ()
{
Super ();
}
Override protected function updatedisplaylist (unscaledwidth: Number,
Unscaledheight: Number): void {
Trace ("W =" + unscaledwidth );
Trace ("H =" + unscaledheight );
VaR G: Graphics = graphics;
G. Clear ();
// G. linestyle (0, 0xff0000 );
G. beginfill (0xff0000, 0.5 );
// G. drawrect (0, 0, unscaledwidth, unscaledheight );
G. drawroundrect (0, 0, unscaledwidth, unscaledheight, 15, 10 );
G. endfill ();
VaR _ w: Number = unscaledwidth;
VaR _ H: Number = unscaledheight;
VaR point1: Point = new point (_ w/3, _ H );
VaR point2: Point = new point (2 * _ w/3, _ H );
VaR point3: Point = new point (0, 2 * _ H );
G. beginfill (0xff0000, 0.5 );
G. moveTo (point1.x, point1.y );
G. lineto (point3.x, point3.y );
G. lineto (point2.x, point2.y );
G. endfill ();
This. Filters = [getdropshadowfilter ()];
}
// Add a shadow
Private function getdropshadowfilter (): bitmapfilter {
VaR color: Number = 0x000000;
VaR angle: Number = 45;
Varalpha: Number = 0.8;
VaR blurx: Number = 8;
VaR blury: Number = 8;
VaR distance: Number = 15;
VaR strength: Number = 0.65;
VaR inner: Boolean = false;
VaR knockout: Boolean = false;
VaR quality: Number = bitmapfilterquality. High;
Return new dropshadowfilter (distance,
Angle,
Color,
Alpha,
Blurx,
Blury,
Strength,
Quality );
}
}
}
We can call the above method in the following custom style.
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" creationcomplete = "initapp ()">
<Mx: style>
Tooltip
{
Borderstyle: inset;
Color: # ffffff;
Borderskin: classreference ("skins. tooltipborderskin ");
}
</MX: style>
<Mx: SCRIPT>
<! [CDATA [
Import MX. Events. tooltipevent;
Import MX. Managers. tooltipmanager;
Private function initapp (): void {
B5.addeventlistener (tooltipevent. tool_tip_show, mov?ltip );
}
Private function movetooltip (Event: tooltipevent): void {
Trace (event );
Event. tooltip. x = b5.x + 5;
Event. tooltip. Y = b5.y-35;
}
]>
</MX: SCRIPT>
<Mx: button id = "B5" width = "30" tooltip = "This is good! "Height =" 20 "x =" 226 "Y =" 167 "/>
</MX: Application>