Tooltip
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Author: | Arthur Clemens |
| Classpath: | org.asapframework.ui.Tooltip |
| File last modified: | Wednesday, 21 February 2007, 16:34:29 |
Tooltip class.
Usage:
- You can customize a Tooltip by either setting properties after creation, or by creating a Tooltip subclass (see further below).
The following code creates a new tooltip:var tip:Tooltip = new Tooltip("tip", _level0, 9999, "Click to enlarge"); tip.create(); tip.setLoc(new Point(100,100));
Change the tooltip properties:tip.backgroundColor = 0x990000; tip.textColor = 0xffffff; tip.textSize = 15; tip.borderWidth = 0; // no border
Set a new text:tip.setText("Click to go back");After (dynamically) setting Tooltip properties, update must be called:tip.update();
To use embedded fonts in the Tooltip, the font should be available in the Flash movie - for instance by placing a dynamic text field with that font embedded offscreen. If you want to use "Monaco" for instance, write:tip.fontName = "Monaco"; tip.textField.embedFonts = true; tip.update();
To use multiple lines, word wrap, set:tip.textField.wordWrap = true;
You can also create a Tooltip subclass. For example://import flash.geom.*; // Still support Flash 7: import org.asapframework.util.types.*; import org.asapframework.ui.Tooltip; class MCTooltip extends Tooltip { public function MCTooltip (inName:String, inTimeline:MovieClip, inDepth:Number, inText:String) { super(inName, inTimeline, inDepth, inText); // set custom properties backgroundColor = 0xffffff; borderAlpha = 20; fontName = "DIN-Light"; textSize = 12; offset = new Point(2, -1); padding = new Point(2, 2); minWidth = 1; maxWidth = 200; // create clips create(); textField.embedFonts = true; // set invisible to make it appear only on rollover the right spot clip._visible = false; } }
To do:
- Fix unwanted wrapping with wordWrap true.
Summary
Constructor
- Tooltip (inName:String, inTimeline:MovieClip, inDepth:Number, inText:String)
- Creates a new Tooltip and optionally sets properties.
Class properties
- BACKGROUND_CLIP_NAME : String
- TEXTFIELD_CLIP_NAME : String
Instance properties
- minWidth : Number
- The minimum width of the tooltip, regardless the amount of text.
- maxWidth : Number
- The minimum width of the tooltip; more text will be displayed on multiple lines.
- borderWidth : Number
- Width of box border.
- borderColor : Number
- Border color.
- borderAlpha : Number
- Alpha blend of border.
- backgroundColor : Number
- Background color; default light yellow.
- backgroundAlpha : Number
- Alpha blend of background.
- fontName : String
- Font name.
- textSize : Number
- Size of text.
- textColor : Number
- Color of text.
- padding : Point
- The inside spacing between text and border.
- offset : Point
- The box offset position from the tip _x and _y position; default (0,0).
- clip : MovieClip
- The Tooltip movieclip and holder of subclips backgroundClip and textField.
- backgroundClip : MovieClip
- Background movieclip.
- textField : TextField
- Text container.
- textFormat : TextFormat
- TextFormat object of textField.
- mName : String
- mTimeline : MovieClip
- mDepth : Number
- mText : String
- mSize : Point
- mLoc : Point
Instance methods
- setText (inText:String) : Void
- Sets a new Tooltip text and redraws.
- setLoc (inLoc:Point) : Void
- Sets the position of the Tooltip.
- update : Void
- Updates and redraws the movieclip.
- create : Void
- Creates the movieclip parts if they do not exist yet: the Tooltip clip, the background clip and the textfield.
- die : Void
- Removes the Tooltip clip parts and calls delete on itself.
- toString : String
- updateTextFormat : Void
- updateSize : Void
- draw : Void
- updateLoc : Void
- drawBackground : Void
- updateBackground : Void
- positionTextField : Void
Constructor
Tooltip
function Tooltip (
inName:String,
inTimeline:MovieClip,
inDepth:Number,
inText:String)
Creates a new Tooltip and optionally sets properties. Will not draw the clip: always call create to create the Tooltip movieclip parts.
Parameters:
inName :
(optional) name of Tooltip movieclip on timeline inTimeline
inTimeline:
(optional) timeline of Tooltip movieclip
inDepth :
(optional) stack depth of Tooltip movieclip
inText :
(optional) Tooltip text contents; may contain html formatting
Class properties
BACKGROUND_CLIP_NAME
static private BACKGROUND_CLIP_NAME:String = "Tooltip_background_mc"
(read)
TEXTFIELD_CLIP_NAME
static private TEXTFIELD_CLIP_NAME:String = "Tooltip_textfield_tf"
(read)
Instance properties
backgroundAlpha
backgroundAlpha:Number = 100
(read)
Alpha blend of background.
backgroundClip
backgroundClip:MovieClip
(read)
Background movieclip. The background color is a box that is drawn onto the background clip.
backgroundColor
backgroundColor:Number = 0xFEF49C
(read)
Background color; default light yellow.
borderAlpha
borderAlpha:Number = 50
(read)
Alpha blend of border.
borderColor
borderColor:Number = 0x8D7F01
(read)
Border color.
borderWidth
borderWidth:Number = 1
(read)
Width of box border. Use 0 for no border.
clip
clip:MovieClip
(read)
The Tooltip movieclip and holder of subclips backgroundClip and textField.
fontName
fontName:String = "Arial"
(read)
Font name. By default the font is not embedded - use
myTip.textField.embedFonts = true; maxWidth
maxWidth:Number = 150
(read)
The minimum width of the tooltip; more text will be displayed on multiple lines.
mDepth
private mDepth:Number
(read)
minWidth
minWidth:Number = 50
(read)
The minimum width of the tooltip, regardless the amount of text.
mLoc
mName
private mName:String
(read)
mSize
mText
private mText:String
(read)
mTimeline
private mTimeline:MovieClip
(read)
textColor
textColor:Number = 0x000000
(read)
Color of text.
textField
textField:TextField
(read)
Text container.
textFormat
textFormat:TextFormat
(read)
TextFormat object of textField.
textSize
textSize:Number = 11
(read)
Size of text.
Instance methods
create
function create (
) : Void
Creates the movieclip parts if they do not exist yet: the Tooltip clip, the background clip and the textfield. Sets default textfield properties.
die
function die (
) : Void
Removes the Tooltip clip parts and calls delete on itself.
draw
private function draw (
) : Void
drawBackground
private function drawBackground (
) : Void
positionTextField
private function positionTextField (
) : Void
setLoc
Sets the position of the Tooltip.
Parameters:
inLoc:
the new position relative of the Tooltip movieclip
setText
function setText (
inText:String) : Void
Sets a new Tooltip text and redraws.
Parameters:
inText:
text contents; may contain html formatting
Implementation note:
- Calls update
toString
function toString (
) : String
update
function update (
) : Void
Updates and redraws the movieclip. Call this function after setting properties.
updateBackground
private function updateBackground (
) : Void
updateLoc
private function updateLoc (
) : Void
updateSize
private function updateSize (
) : Void
updateTextFormat
private function updateTextFormat (
) : Void