View Full Version : Simple rollover request

07-12-2001, 09:20 PM
I'm totally new to Flash and totally frustrated!

Will SOMEONE please tell me how do you make a button which when rolled over plays a mc and when rolled out plays another movie clip, or the first clip in reverse. As in a menu which slides in when you rollover it and slides back out when you roll out.

I know this is simple. But please help. Need this quick too! thanks!

07-15-2001, 09:15 AM
It seems really complicated but actually, once you've done it, you realise how easy it is. It's not a 'purist' method of doing it, but it's really effective. There are actually lots of ways to do this, but this is the one I use because it disables the button until the most recent interaction from the user has been dealt with.

( step 1) Create a movieclip called 'main'.

(step 2) Inside this place your button, on it's own layer.

(step 3) Make the timeline of 'main' 21 frames long.

(step 4) Create keyframes on the button layer at frames 1, 2, 11, and 12.

(step 5) Create a new layer and call it 'actions' (Or whatever you like).

(step 6) On the 'actions' layer place 'stop' actions at frames 1 and 11, and place a 'gotoAndStop (1)' at frame 21. [It's very important NOT to use gotoAndPlay.]

(step 7) Create a new layer and call it 'movieclip' (Or whatever you like).

(step 8) On the 'movieclip' layer, leave frame 1 as a blank keyframe. Starting at frame 2 place your movieclip that you want the button to introduce.

(step 9) Introduce the movieclip by sliding in, or fading in (or whatever you like) from frame 2 to frame11, where frame 11 is the movieclip in it's full glory. You may want to add another layer to help with this.

(step 10) Do the same thing for the movieclip exiting, from frame 12 to frame 21, where frame twelve is the movieclip in it's full glory.

(step 11) Back on the 'button' layer, NOT on keyframe 1, but on every other keyframe, extend the 'hit' state of the button to encompass the area taken by the movieclip it's controlling. This is vital to the process and allows you to place buttons in the movieclip. Because it's not done in frame 1 it doesn't effect the 'hit' area of the button on the main stage.

(step 12) On the button layer attatch to the button in frame 1 the following actionscript:

on (rollOver) {
gotoAndPlay (2);

(step 13) Attatch to the button in frame 11 the following actionscript:

on(rollOut) {
gototAndPlay (12);

(step 14) Place 'main' movieclip on the stage.

(step 15) You have to use the test movie function to see it working.

What it does is side step actually attatching the movieclip to the button. The introduction and then the exit of the movieclip are side effects, rather than direct results of rolling over and then off of the button. Because there's no actionscript attatched to the buttons in frames 2, 12 and 21, the movieclip will finish it's introduction or exit before the button can cause it to do anything else. Because you extended the hit area, for the periods when the movieclip was visible, you can place other buttons here, you have to use paths to get them to work though.

It's worth noting that if you use too many of these it can seriously increase the download of the movie, but a few don't hurt. I hope it helps. If you have any problems, just email me. ;o)

07-23-2001, 07:53 PM
could you maybe outline how to use paths. I am not sure I understand the word 'path' in this context.


07-24-2001, 02:36 AM
see the paths tutorial

07-24-2001, 08:27 AM
What I meant by paths was relative or absolute paths, as Jesse points out there is an excellent tutorial on this site.

If you want to produce a movieclip that slides out when a button is clicked on, use my instructions above. If you want further buttons on that MC:

Do the same as above. In the movie clip that appears/ dissappears put your buttons. If you want them to effect the main time line (move it to frame 20 for example), the actionscript would be:

on (release){

If you wanted them to effect the movie clip that they were in (the one that appears/dissappears) the actionscript would be:

on (release){

You can of course instead of having buttons, have more appearing/dissappearing MCs. When it gets this complicated use the Movie Explorer to work out where you are and what's effecting what. It's the enlarging and shrinking of the 'hit state' of the original button that allows you to do this. If you want to have two levels of MCs appearing and dissappearing with buttons on the lowest one, you need to increase the original button's hit area some more, or the whole thing will close.

This can be done by placing the button in a MC with two frames. The first is as discussed in my previous post, the second identical but with a hit area large enough to cover the new MCs appearing/dissappearing. What ever action you use to open the final MC's also moves the button MC to the second frame, closing them moves it back to the first frame (Don't forget the 'stop();' s)

I'm going to leave it at that because I find it hard to explain verbally. Hope that helps :o) Email if there's a problem.