#1
  1. No Profile Picture
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Newcastle, UK
    Posts
    19
    Rep Power
    0

    Wink Flash MX - Mouse Event


    Hi,

    Recently upgraded to MX, only to find to my horror that the flash5 version of doing 'onMouseover tell target' doesn't appear to be obvious in the new MX actionscript. Anybody know how I can set a movieclip to tell target via a rollover using the new actionscript?

    Cheers,
    Ryan
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    Hamilton, Ontario
    Posts
    3
    Rep Power
    0

    Post


    You can get easy mouse over detection for any movie clip by creating a prototype function for the MovieClip class. I generally do the following:

    1. Define the prototype in the first frame of the root level

    Code:
    MovieClip.prototype.mouseOver = function() {
      if (this.hitTest (_root._x, _root._y) == true) {
        return true;
      } else {
        return false;
      }
    }
    2. Now every movie clip on the stage has the ability to call mouseOver() on itself, which will return either true or false.

    For example, a movie could perform these actions:

    Code:
    onClipEvent (mouseMove) {
      if (this.mouseOver() == true) {
        ...
      }
    }
    Or to make a movie clip act like a button, you could do this:

    Code:
    onClipEvent (mouseDown) {
      if (this.mouseOver() == true) {
        ...
      }
    }
    Matt
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Location
    Mpls
    Posts
    1
    Rep Power
    0
    Use these:
    Code:
    mc1.onRollOver = function() {
    	trace(this._name);
    }
    mc2.onRollOver = function() {
    	trace(this._name);
    }
    The mouseOver event(s) are listener-based. That's why they weren't working the way you expected them to. You can look up listeners in the reference panel for more information.

    Hope that helps...

IMN logo majestic logo threadwatch logo seochat tools logo