How to make a button animation finish animating after mouse leaves

Posted on 2003-11-29
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
  • 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 30 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 20 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to disable  HTML5 video in chrome 2 1,541
Flash Player White Screen Facebook 5 750
Crash with shockwave flash 8 237
You Tube Videos not playing 9 116
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now