Play and reverse MC within a button

Hey, I’m trying to create an animated button which contains a movie clip in the over state which plays forward and then reverses. I have the MC working when its playing strictly on the root, but when its enbeded within the button it doesn’t function.

Heres what I have:

button -> mc on over state of button with a stop action at the end of the forward animation and a gotoAndStop(1) action at the end of the reverse animation.

attached to the MC I have ->
on (rollOver) {
_root.newsMC.gotoAndPlay(1)
}
on (rollOut) {
_root.newsMC.gotoAndPlay(6)
}

Does anyone have a remedy?

There was a whole thread on how to get things to play backwards…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=11427

Thanks, I read through the other thread but I’m still having problems. If you embed a movie clip within a button, (such as in the over state) does that cause problems in calling that MC using actionscript? My actionscript only works when the MC is directly placed on the stage.

Yeah, because you can only have it work on the stage. The over state of a button clip is only triggered when the mouse is over, if you mouse off, then the animation cannot be viewed in any way.

What you could do is use a movie clip symbol as a button. Flash MX allows you do use on handlers on movie clips as well, where is the previous flash versions only allowed you to use on handlers on button symbols.

Ok, with that say, create your movie clip symbol. Inside the clip create your tween animation.

Then go back to the stage that contains your movie clip symbol and right click on it and open the actions panel. Inside the actions panel apply these actions…

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

This constantly checks if the mouse is over the button using hitTest(). If the mouse is over the button, then it plays the next frame (remember it constantly checks on enterFrame so it will keep playing nextFrame() hence playing the tween), else it will play the prevFrame() which will play the animation backwards :wink:

Thanks that works perfectly, it was driving me crazy why it didn’t work before.

Now what happens if I only want a certain area of my movie to function as a bounding box for my mouse over?

For example I have the MC that contains a box with a shadow below, but I only want the animation of the box to occur when the mouse is over the box and not occur when its over the shadow. Do I need to place the shadow in a different MC or can I specify a certain range of x and y coordinates as the button area?

Thanks for you help.

Probably the easiest way would to put the shadow in a different MC.

Either that, or create that box into an MC and have the animation inside that MC. And apply the last actions to that mc instead of the main one.