Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MacDonaldsd

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
London , UK
Im doing a website in flash and I want to have a floating text box appear when the user hovers there mouse over a link.

I just can't work out the actionscript to do it

Can anyone help ?
 
By 'floating' do you mean that it appears at a point relative to the mouse pointer? If so, there are a few ways that you could do it- probably the easiest is this:

Create a text box, convert it to a movieclip and position it off-stage. Give it an instance name and then add this actionscript to the movie:

Code:
onClipEvent(load) {
  // set clip invisible
  this._visible=false;
}

Next choose the clip or button that you want to add the mouse over event to. If it's a movieclip, you'd write this, to set the clip visible or invisible:

Code:
onClipEvent(load) {
  // set up function for mouse over
  this.onRollOver = function() {
    // use '_root' only if your text box clip is on the main timeline, or root
    _root.myTextBox._visible = true;
  }
  this.onRollOut = function() {
    _root.myTextBox._visible = false;
  }
}

Then go back to your text box clip, and add this code after the onClipEvent(load) part.

Code:
onClipEvent(mouseMove) {
  // keeps clip positioned 10px away from mouse pointer
  this._x = _root._xmouse + 10;
  this._y = _root._ymouse + 10;
}

So this code would set the clip invisble or visible on rollover/out, and you'd change the values added to the mouse x/y point to position it relatively.
Another way to do this would be to use attachMovie, I can show you how to do this if you need to.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.