<http://abdulcode.wordpress.com/author/abduljas/>  Flex4/AS3: Custom
Tooltip - 
ToolTipManager<http://abdulcode.wordpress.com/2010/12/24/flexas3-custom-tooltip-tooltipmanager/>
*Abdul <http://abdulcode.wordpress.com/author/abduljas/>* | December 24,
2010 at 4:06 pm | Categories:
AS3<http://abdulcode.wordpress.com/?category_name=as3>,
Flex <http://abdulcode.wordpress.com/?category_name=flex> | URL:
http://wp.me/p1fUGK-1h

The Tootip is created using the ToolTipManager.

In this example the Tooltip move with the Cursor on the Object(Circle).

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:mx="library://ns.adobe.com/flex/mx"
                           width="100%"
                           height="100%"
                           initialize="init();">

        <fx:Script>
                <![CDATA[
                        import mx.core.UIComponent;
                        import mx.managers.ToolTipManager;

                        private function init():void
                        {
                                //ToolTipManager.showDelay = 0;
                                var circle:Sprite = new Sprite();
                                with (circle.graphics)
                                {
                                        beginFill(0xFFCC00);
                                        drawCircle(200, 200, 100);
                                        endFill();
                                }

                                var uicomp:UIComponent = new UIComponent();
                                uicomp.addChild(circle);

                                uicomp.addEventListener(MouseEvent.MOUSE_MOVE, 
onMouseMove);
                                uicomp.addEventListener(MouseEvent.MOUSE_OUT, 
onMouseOut);
                                addElement(uicomp);
                        }

                        private var tooltipp:*;

                        private function onMouseMove(e:MouseEvent):void
                        {
                                var X = e.localX + 20;
                                var Y = e.localY + 50;

                                if (tooltipp)
                                {
                                        ToolTipManager.destroyToolTip(tooltipp);
                                        tooltipp = null;
                                }

                                var value:String = "Position : (" + X + ", " + 
Y + ")"
                                tooltipp = ToolTipManager.createToolTip(value, 
0, 0);

                                // calculate the tooltip coordinates
                                var pt:Point = new Point(X, Y);
                                pt = e.currentTarget.contentToGlobal(pt);
                                pt.x = pt.x + 10 - tooltipp.width / 2;
                                pt.y = pt.y - tooltipp.height;

                                tooltipp.x = pt.x;
                                tooltipp.y = pt.y;
                        }

                        private function onMouseOut(e:MouseEvent):void
                        {
                                if (tooltipp)
                                {
                                        ToolTipManager.destroyToolTip(tooltipp);
                                        tooltipp = null;
                                }
                        }
                ]]>
        </fx:Script>
</s:Application>

  Add a comment to this
post<http://abdulcode.wordpress.com/2010/12/24/flexas3-custom-tooltip-tooltipmanager/#respond>
  <http://feeds.wordpress.com/1.0/gocomments/abdulcode.wordpress.com/79/>
<http://feeds.wordpress.com/1.0/godelicious/abdulcode.wordpress.com/79/>
<http://feeds.wordpress.com/1.0/gofacebook/abdulcode.wordpress.com/79/>
<http://feeds.wordpress.com/1.0/gotwitter/abdulcode.wordpress.com/79/>
<http://feeds.wordpress.com/1.0/gostumble/abdulcode.wordpress.com/79/>
<http://feeds.wordpress.com/1.0/godigg/abdulcode.wordpress.com/79/>
<http://feeds.wordpress.com/1.0/goreddit/abdulcode.wordpress.com/79/>

-- 
*With Regards,
Abdul <https://abdulthink.wordpress.com/>**
*

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to