Flash AS3 Button Up-Down Effect

How can I get my buttons to move down with MOUSE_DOWN, and back up whether the MOUSE_OUT or MOUSE_UP event occurs?
If I have MOUSE_OUT move the button -2 x,y it does it whenever I roll over the button...

I'm using movieClips instead of buttons... I'd rather keep it that way, if possible (instead of convert each to a button to use built-in features).

AS3-----------------
home_i.addEventListener(MouseEvent.MOUSE_DOWN, fx_down);
function fx_down(event:MouseEvent):void
{
      event.target.x = event.target.x + 2;
      event.target.y = event.target.y + 2;
}

home_i.addEventListener(MouseEvent.MOUSE_UP, fx_pause);
function fx_pause(event:MouseEvent):void
{
      event.target.x = event.target.x - 2;
      event.target.y = event.target.y - 2;
}
tlengnickAsked:
Who is Participating?
 
blue-genieCommented:
i'm not sure what you're trying to do.
if you want it to move down on mouse over and mouse down, and revert back to original position when mouse down or mouse out, simply add 4 listeners.
0
 
tlengnickAuthor Commented:
Sorry. I realize I didn't explain the problem!

Based on the way I have it coded above, the user could hold the mouse down over the button, triggering the MOUSE_DOWN function (and moving the button +2x +2y), but if while continuing to hold the mouse down the user moves it away from the button and then releases, the MOUSE_UP function (moving the button -2x -2y, i.e., back in place) never occurs.

The button would stay "depressed", and the user could move it another +2x +2y by clicking on it again, eventually moving it off the stage.
0
 
ProactivationCommented:
Try this instead:

stage.addEventListener(MouseEvent.MOUSE_UP, fx_pause);

Open in new window

0
 
tlengnickAuthor Commented:
Thank you both for the suggestions -- I actually used each for different solutions!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.