Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


How to make a button animation finish animating after mouse leaves

Posted on 2003-11-29
Medium Priority
Last Modified: 2010-04-03
I have a button, and in its over state is a movie clip.  The idea is make the button animate when the mouse hovers over it.  The problem is that it only animates while the mouse is over the button, and stops animating if the user moves the mouse off the button.  Is there anyway to make the animation finish even after the user's mouse is not over the button?  I don't mind if the animation goes continually while the mouse is over the button, I just want it to run to the last frame after the mouse leaves the button (rather than stop right away).  I'm somewhat new to flash mx, so if there is a better way to do what I want, please feel free to suggest it.  Thanks.

Question by:prattm
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 9844313
Take the movie clip out of the button and put it on the main scene. Then give that movie clip an instance name like "MC1"
Then add this code on your button.

button1.onRollOver = function () {     //button1 is the instance name of your button
     _root.MC1.gotoAndPlay(2);          //This tells flash to start playing your mc when the mouse is over your button



Author Comment

ID: 9844461
That seems to work, except the animation is constantly playing when the mouse is not over the button.  Is there a way to only animate it when the button has been hovered over?


Accepted Solution

OBCT earned 90 total points
ID: 9844531
Just add a stop tag at the end of the animation.


That will prevent the animation from looping.


LVL 23

Assisted Solution

Zeffer earned 60 total points
ID: 9844635
OBCT forgot to tell you that you need to put an empty frame with a stop
on the first frame of the animation..so it sits unseen on the stage..then plays on mouseover ..and stops at the end..independant of the button action


Expert Comment

ID: 9918444

Please post a comment to let us know how your going and if you need any more help.



Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

618 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