Floating text box in Flash

Discussion in 'Web Design and Development' started by MacDonaldsd, Dec 3, 2006.

  1. MacDonaldsd macrumors 65816


    Sep 8, 2005
    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 ?
  2. londonweb macrumors 6502


    Sep 14, 2005
    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:

    onClipEvent(load) {
      // set clip invisible
    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:

    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.

    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.

Share This Page