?
Solved

Flash AS3 Button Up-Down Effect

Posted on 2012-09-14
4
Medium Priority
?
741 Views
Last Modified: 2012-09-19
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;
}
0
Comment
Question by:tlengnick
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
blue-genie earned 1200 total points
ID: 38401278
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
 

Author Comment

by:tlengnick
ID: 38401797
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
 
LVL 12

Assisted Solution

by:Proactivation
Proactivation earned 800 total points
ID: 38413178
Try this instead:

stage.addEventListener(MouseEvent.MOUSE_UP, fx_pause);

Open in new window

0
 

Author Closing Comment

by:tlengnick
ID: 38413345
Thank you both for the suggestions -- I actually used each for different solutions!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question