Solved

tooltips

Posted on 2008-06-11
9
274 Views
Last Modified: 2013-11-05
i found a tooltip class on the web that works quiet well: http://theflashblog.com/?p=16

- if the text is longer than the length of the tooltip, some of the text gets cut off.  
- if the tooltip is displayed near the edge of the movie, part of the tooltip is hidden.

how can i fix this please?

i can provide simple move if required.....

Ellandrd
var tooltip:Tooltip = new Tooltip(0xFFFFEC,0x000000);

tooltip.showTip("Sean Delaney");

 

class Tooltip 

{	

	private var theTip:MovieClip;

	private var theFormat:TextFormat;

	

	function Tooltip(hex:Number,hex2:Number) 

	{

		this.theTip = _root.createEmptyMovieClip("tooltip", _root.getNextHighestDepth());

		this.theTip.createTextField("theText",this.theTip.getNextHighestDepth(),3,1,125,20);

		this.theTip.beginFill(hex);

		this.theTip.lineStyle(1, hex2, 125);

		this.theTip.moveTo(0, 0);

		this.theTip.lineTo(125, 0);

		this.theTip.lineTo(125, 20);

		this.theTip.lineTo(20, 20);

		this.theTip.lineTo(15, 30);

		this.theTip.lineTo(10, 20);

		this.theTip.lineTo(0, 20);

		this.theTip.lineTo(0, 0);

		this.theTip.endFill();

		this.theTip._visible = false;

		this.theTip.theText.selectable = false;

		this.theFormat = new TextFormat();

		this.theFormat.font = "Arial";

		this.theFormat.size = 11;

		this.theFormat.align = "center";

		this.theTip.theText.setNewTextFormat(this.theFormat);

	}

	

	public function showTip(theText:String):Void 

	{

		this.theTip.theText.text = theText;

		this.theTip._x = _root._xmouse - 15;

		this.theTip._y = _root._ymouse - 35;

		this.theTip._visible = true;

		this.theTip.onMouseMove = function() 

		{

			this._x = _root._xmouse-15 ;

			this._y = _root._ymouse-35;

			updateAfterEvent();

		}

	}

	

	public function removeTip():Void 

	{

		this.theTip._visible = false;

		delete this.theTip.onEnterFrame;

	}

}

Open in new window

0
Comment
Question by:ellandrd
  • 3
  • 3
9 Comments
 
LVL 12

Accepted Solution

by:
williamcampbell earned 500 total points
ID: 21761757
When you go to the edge of the movie it tries to diaply the tip at
                  this._x = _root._xmouse-15 ;
                  this._y = _root._ymouse-35;

 -15 points behind the mouse

So Change to

this._x = _root._xmouse-15 ;
if ( this._x < 0 ) this._x = 0;
this._y = _root._ymouse-35
if ( this._y < 0 ) this._y = 0;

As far as the text getting cropped this line restricts that
  this.theTip.lineTo(125, 0);     // the 125 is the length of the tip

 You cange change *all* the 125's to say 256  or you will need to find the length of the text based on its font etc

Hope this helps

William




0
 
LVL 16

Author Comment

by:ellandrd
ID: 21763244
still hasnt fixed the toolip position on edge of movie... try it youself
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 21763310
Can I see your new Code?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Author Comment

by:ellandrd
ID: 21763346
class Tooltip {
      private var theTip:MovieClip;
      private var theFormat:TextFormat;

      function Tooltip(hex:Number, hex2:Number) {
            this.theTip = _root.createEmptyMovieClip("tooltip", _root.getNextHighestDepth());
            this.theTip.createTextField("theText",this.theTip.getNextHighestDepth(),3,1,125,20);
            this.theTip.beginFill(hex);
            this.theTip.lineStyle(1,hex2,125);
            this.theTip.moveTo(0,0);
            this.theTip.lineTo(125,0);
            this.theTip.lineTo(125,20);
            this.theTip.lineTo(20,20);
            this.theTip.lineTo(15,30);
            this.theTip.lineTo(10,20);
            this.theTip.lineTo(0,20);
            this.theTip.lineTo(0,0);
            this.theTip.endFill();
            this.theTip._visible = false;
            this.theTip.theText.selectable = false;
            this.theFormat = new TextFormat();
            this.theFormat.font = "Arial";
            this.theFormat.size = 11;
            this.theFormat.align = "center";
            this.theTip.theText.setNewTextFormat(this.theFormat);
      }
      public function showTip(theText:String):Void {
            this.theTip.theText.text = theText;



            this.theTip._x = _root._xmouse-15;

            if (this.theTip._x<0) {
                  this.theTip._x = 0;
            }
            this.theTip._y = _root._ymouse-35;


            if (this.theTip._y<0) {
                  this.theTip._y = 0;
            }


            this.theTip._visible = true;
            this.theTip.onMouseMove = function() {
                  //this._x = _root._xmouse-15 ;
                  //this._y = _root._ymouse-35;


                  this._x = _root._xmouse-15;

                  if (this._x<0) {
                        this._x = 0;
                  }

                  this._y = _root._ymouse-35;
                  if (this._y<0) {
                        this._y = 0;
                  }

                  updateAfterEvent();
            };
      }
      public function removeTip():Void {
            this.theTip._visible = false;
            delete this.theTip.onEnterFrame;
      }
}
0
 
LVL 16

Author Comment

by:ellandrd
ID: 21777494
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 21780937
I Object. I spent some time on this question. The Asker got an answer from another question thread. I should at least get something for my effort. If the asker is asking the same question in two threads and only accepting one that I believe is bad form.

WC
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SWF won't scale? 4 520
Flash movie or gif/animation? 3 872
Got "Shockwave has crashed : reload?" when viewing in multiple tabs of Chrome 4 86
Flash ActionScript 6 43
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now