0
votes

I'm having some problems while making a button for a site. I created a button and an animation, then imported that animation as an .swf to the button file. I used the following code(with btn being the button and mc the movie clip):

btn.addEventListener(MouseEvent.MOUSE_OVER,btnF);
function btnF(e:MouseEvent):void
{
    mc.play();
}

As you can imagine, when the mouse is over the button, the animation plays, but it doesn't stop... Any Solutions?

Details: Using Actionscript 3.0
And yes, i made the movie clip with a stop() code at the end... so I don't see why it loops.

3

3 Answers

0
votes

It might be simpler to do it this way: create a button, on default state have the graphic for the button. On the over state use a movieclip with your animation. That should work without any code

0
votes

The problem is that the MOUSE_OVER event will always fire if the mouse is over that "btn" display object. So the stop() code works at the end, but the play overwrites that command.

Here is a possible solution:

btn.addEventListener(MouseEvent.MOUSE_OVER, btnF);
function btnF(e:MouseEvent):void{
{
     if(mc.currentFrame == 1)
     {
          mc.play();
     }
}
-1
votes
//i called the instance of the button : buthead and the instance of the movie clip : head_mc
//on the first frame of the movie clip, i've put a stop function

buthead.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent):void {
    head_mc.play();
});