0 Replies Latest reply on Jul 5, 2006 7:53 PM by hushhurt

    Mouse Linsteners

    hushhurt Level 1
      I have a question regarding listeners.

      Here is my code:

      var myInterval:Number;
      musicPlayer._alpha = 0;

      Mouse.addListener(myListener);

      myListener.onMouseMove = function() {
      if (aHitArea.hitTest(_root._xmouse, _root._ymouse, true)) {
      myInterval = setInterval(mChange, 5);
      }
      };

      function mChange() {
      musicPlayer._alpha++;
      updateAfterEvent();
      if (musicPlayer._alpha == 100)
      clearInterval(myInterval);
      }


      now, how would you suggest me fading the alpha on musicPlayer when the mouse is off the aHitTest area?

      I added an else statement:

      myListener.onMouseMove = function() {
      if (aHitArea.hitTest(_root._xmouse, _root._ymouse, true)) {
      myInterval = setInterval(mChange, 5);
      } else if (bHitArea.hitTest(_root._xmouse, _root._ymouse, true)) {
      musicPlayer._alpha = 0;
      }
      };

      but that only changes the alpha to 0 for a second then sets it back to 100.

      i know this is a long one, but any help is always appreciated.

      also, on listners and mousemove - does this affect the cpu cycles? at some point should i removeListener?

      thanks again