Note that there are some explanatory texts on larger screens.

plurals
  1. PODifferent tooltips for different parts of a component in Action Script
    text
    copied!<p>I want to have a tooltip that shows different things when the mouse goes over a different part of a component. For example if it is the top half of a component it will show one tooltip. If the mouse is on the bottom half of the segment then the tooltip will be another. I have some code I have written that returns a panel with string in. This code is on another computer so I'll post code tomorrow. </p> <p>Is it possible in ActionScript to have different tooltips (or rather differnt values in a tooltip) for different parts of a segment?</p> <p>The code I have so far is:</p> <p>MyToolTip.mxml</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" implements="mx.core.IToolTip" alpha=".9" width="325" borderColor="black" borderStyle="solid" cornerRadius="10" horizontalAlign="center"&gt; &lt;mx:Script&gt;&lt;![CDATA[ [Bindable] public var toolTipText:String = ""; public var _text:String; [Bindable] public function get text():String { return _text; } public function set text(value:String):void {} ]]&gt;&lt;/mx:Script&gt; &lt;mx:HBox width="100%" height="100%"&gt; &lt;mx:Text text = "Text here" width = "50%"/&gt; &lt;mx:Text text = "{toolTipText}" width = "50%"/&gt; &lt;/mx:HBox&gt; &lt;/mx:Panel&gt; </code></pre> <p>And then my action script class component that I want the tooltip to be against.</p> <pre><code>public class MyComponent extends mx.containers.VBox { private var tt:MyToolTip public function MyComponent() { this.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, toolTipCreateHandler); this.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler); tt = new MyToolTip(); } override protected function drawFigure():void { //Need to kick the TOOL_TIP_CREATE event...and needs to be a value (eg a SPACE). //If blank then no tooltip is created this.toolTip = " "; super.drawFigure(); } private function toolTipCreateHandler(event:ToolTipEvent):void { var toolTipText:String = "tooltip1"; eventToolTip.toolTipText = toolTipText; event.toolTip = tt; } private function mouseOverHandler(event:MouseEvent):void { //perhaps I need to be more efficient here and only fire //when the mouse goes into top half or bottom half //This does not appear to update the toolTipText in the view var halfwayUp:Number = getBounds(this).height / 2; if (event.localY &lt; halfwayUp) { eventToolTip.toolTipText = "tooltip2"; } else { eventToolTip.toolTipText = "tooltip1"; } } } } </code></pre> <p>Any help or pointers in how to update the tooltip when it is already displaying would be great.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload