Here is the code for creating a tool tip for any given node.  I have played with opacity of source node. You can remove that part if you dont want. 

/**
 * @author Raghu Nair
 */

public class TooltipNode extends CustomNode{


    /* Source node where you want to show the tool tip */
    public-init var sourceNode:Node;

    /* Tool tip text */
    public-init var tooltip:String;

    /* Width */
    public-init var width :Integer = 80;



    var glowColor = Color.TRANSPARENT;
    override var opacity = 0.0;
    def showTip:Timeline = Timeline {
        keyFrames: [
            at (0s) {
                glowColor => Color.TRANSPARENT;
            opacity => 0.0;
            },
            at (1s) {
                glowColor =>Color.color(0.5, 0.5, 0.5, 0.5);
                opacity => 1.0 tween Interpolator.EASEBOTH;
            },
        ]
    }

    var rectangle:Rectangle = Rectangle{
        translateX: bind ( sourceNode.translateX+(sourceNode.layoutBounds.width - rectangle.layoutBounds.width )/2)
        translateY: bind (( sourceNode.layoutBounds.height/2) + 45);
        fill:Color.YELLOW
        width:width
        height:25
    }

    var text:Text = Text {
        translateX: bind (rectangle.translateX )
        translateY: bind rectangle.translateY+(rectangle.layoutBounds.height / 2) + 3
        font: Font {
            size: 11
        }
        fill: Color.BLUEVIOLET
        content: bind tooltip
    }

    override function create():Node {
        sourceNode.onMouseEntered = function(e:MouseEvent){
            sourceNode.opacity = 1.0;
            showTip.rate = 1.0;
            showTip.playFromStart();
        }
        sourceNode.onMouseExited =  function(e:MouseEvent){
            sourceNode.opacity = 0.7;
            showTip.rate = -1.0;
            opacity = 0.0;
        }
        Group{
            content: [rectangle,text]
       }

    }
}

Comments:

Have a iPhone and want to diversify your ringtone? This amazing http://www.mp3tom4rconverter.com can definitely help you out.

Posted by WMV Converter OS X on May 07, 2009 at 08:18 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by Raghu Nair