Reverse a button

Did a search and found nothing so if it has been coverd sorry.

I want a button that whne u rollover does the aniamtion but if u rollout it stops where it is and plays back.

Up until now i have jsut been putting hte same aniamtion in the Up state and in the over state jsut reversed. So when the button is in its up state it jsut plays the reverse of the over state. This cna lead to a choppy look cause if you mouse off fast enough it looks like it jumps to the last frame then plays.

I’ve uploaded a FLA of my current way of doing button aniamtions BUTTON FLA

So if every one is confused now any ideas?

Try using hitTest, this is all over the forum actually. Here’s an example FLA.

ahhh finally something I know how to do.

Just put this script in the symbol’s actions

[AS]
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.nextFrame();
} else {
this.prevFrame();
}
}
[/AS]

*note if the user rolls off the button and off the movie clip too quickly it will freeze in its rewind motion and will stay there until the user rolls over it again. But you don’t need to worry about this unless your movie is right next to the edge of the movie’s border.

Digigamer, you’re a bit late, that’s exactly what my example file is. :stuck_out_tongue:

feck well at least with mine he doesn’t have to dl anything >_<

Thanks man. I jsut didnt’ know what i was looking for. I had read about it before but couldnt’ remember what he code looked like.

I say obfuscate the darn thing!! :stuck_out_tongue:
[AS]myMovieClip.onEnterFrame = function() {
var hit = this.hitTest(_root._xmouse, _root._ymouse, true);
this.gotoAndStop(this._currentframe+hit-!hit);
};[/AS]

wow that is pretty tight optimization kode. You seem to be good with funcitons which i’m jsut getting used to.

Lets say i have 6 MC’s that i wnat to apply this too. How do u apply one function to multiple objects?

hehe - Thanks. =)

There are a couple (surely more) things you could try…

  1. Store the instance name of the MovieClips in an Array
    [AS]myClips = [myClip1, myClip2, etc, etc];
    for (i=0; i<myClips.length; myClips++) {
    myClips*.onEnterFrame = function() {
    var hit = this.hitTest(_root._xmouse, _root._ymouse, true);
    this.gotoAndStop(this._currentframe+hit-!hit);
    };
    }[/AS]
  2. Define it as a Method
    [AS]MovieClip.prototype.backAndForth = function() {
    this.onEnterFrame = function() {
    var hit = this.hitTest(_root._xmouse, _root._ymouse, true);
    this.gotoAndStop(this._currentframe+hit-!hit);
    };
    };
    myClip1.backAndForth();
    myClip2.backAndForth();
    etc.backAndForth();
    etc.backAndForth();[/AS]

wow i’m glad i can at least understand the code. I can’t wirte it worth a crap. This will great help thanxs man.

You’re welcome, sintax. :wink:

man that array method works liek a charm. You have jsut saved me a ton of coding time on every project.

Yup! Arrays are a really time/coding saver. You gotta love 'em!! :stuck_out_tongue: