"There is no way of forcing the user to watch the animation, because you
are giving him the option to either see it or take his mouse off of the
button and not see it.there is a way...."
Sure there is. Let the animation movie clip be the button. I'm sure this is
not the most efficient way, but it may be easiest to understand:
Start with the MovieClip which is the animation in the Over state of the
buttton. Let's say it's a square which rotates through a tween 180 degrees
in 10 frames.
Put a new keyframe before the first frame, so that the length of the
animation is one frame longer, and make Frame 1 look just like Frame 2. In
the new Frame 1, put an Action that says: stop();
Put a keyframe in the last frame of the animation. In that keyframe, put an
action that says:
gotoAndPlay(2);
Select frames 2-10 of the animation. Copy them. Paste them at the end of the
animation so that now the timeline of the animation is twice as long.
So now you've got a 21 frame animation, the timeframe of which contains two
identical loops of the animation. It has a stop in frame 1, which looks just
like frame 2. Left to its own devices, of course. it would just stop at
frame 1. But if you somehow tell it to start playing, it plays through until
it reaches the end of the first loop (frame 11) and then jumps to frame 2.
So it leapfrogs the stop in Frame 1 and loops indefinitely from frames 2-11.
Now put an instance of this Movie Clip on the Stage. Select it and attach to
it a script something like this:
onClipEvent(load){
this.gotoAndStop(1);
}
on (rollOver){
this.gotoAndPlay(2);
}
on (rollOut){
this.gotoAndPlay(this._currentFrame+=10);
}
So the Movie Clip (which we're using as an animated button) is stopped when
it loads. On mouseover, it loops indefinitely between frames 2-11. On
mouseout it jumps 10 frames to a frame which looks just like the current
frame. That is, if it's at frame 5 when you mouseout, it jumps to frame 15
and plays to frame 21, after which it loops to frame 1 and stops.
Like I say, this is no doubt kid stuff to more accomplished scripters here,
and I suspect the whole thing could be done more elegantly (with a doWhile
statement?), but anyway, it works and is easy to understand.
JET