You can apply a programmatic skin to ToolTip controls.
ToolTip skins are defined by the ToolTipBorder programmatic skin. This file is located in the mx.skins.halo package.
To reskin ToolTips, you edit the ToolTipBorder class file, and then apply the new skin to the ToolTip by using CSS. For more information on skinning, see Creating Skins.
//package mx.skins.halo { // Old package name
package { // New, empty package
//public class ToolTipBorder extends RectangularBorder // Old name public class MyToolTipBorder extends RectangularBorder // New name
//public function ToolTipBorder() // Old constructor public function MyToolTipBorder() // New constructor
//include "../../core/Version.as";
The following example adds a red tinge to the background of the ToolTip's box by replacing the default backgroundColor property with an array of colors:
var highlightAlphas:Array = [0.3,0.0];
drawRoundRect(3, 1, w-6, h-4, cornerRadius, [0xFF0000, 0xFFFFBB],
backgroundAlpha);
The values of the cornerRadius and backgroundAlpha properties that are shown in the previous code snippet are set earlier in the updateDisplayList() method.
<?xml version="1.0"?>
<!-- skins/ApplyCustomToolTipSkin.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Style>
ToolTip {
borderSkin: ClassReference("MyToolTipBorder");
}
</mx:Style>
<mx:Button id="b1" label="Click Me" toolTip="Click this button"/>
</mx:Application>
You must specify the full package name in the CSS reference. In this example, the file MyToolTipBorder.as is in an empty package and, therefore, has no package designation such as mx.skins.halo.
If the skin class is in the same directory as the application, you do not have to add its location to the source path. The current directory is assumed. For more information, see Using the Flex Compilers.