Button over animated Button

Hi,

I posted this in Flashkit and no one seemed to be able to help. Maybe you guys can take a look. Thanks! :slight_smile:

Ok maybe there’s an easier way to do this, and if there is, please let me know.

I’m trying to create a sort of “slide out” panel with buttons on it.

For the panel itself, I’m using a button with the “off” state being a static symbol graphic. The “on” state is a movie symbol that “shoots” a panel outward.

What I want to do is incorporated buttons on the actual panel when it shoots outward. I’ve tried making separate buttons and putting it into the movie symbol for the panel when its done “shooting out”, but when I run the clip, whenever I put my mouse over the actual buttons, the movie just goes berserk (meaning it ignores all my action scripts to tell it to stop shooting out and back).

I suspect this has something to do with the “hit” area.

Any suggestions?

THanks!

Don’t put your animation in the over state of the button, just use the clip on it’s own under an invisible button (that makes it gotoAndPlay (animationframe), first frame containing a stop)

Hi,

Thanks for your help. I’m not all that familiar with action script so I was wondering if you could help with that.

So I create a movie clip with the first frame stopped. I want to have it so that when my mouse slides over the movie, it does gotoAndPlay(2). I am, however, not quite sure of the “mouse-over” command that I should use. The only one I saw in the function list is “on(press)”. but that would mean the person needs to press the clip… and I’m assuming that works only on buttons…

So in short, here’s an algorithm I think I want it to do:

(For frame 1):

if (onMouseOver) // mouse goes over area
{
gotoAndPlay(2); // play frame 2
}
else
{
stop(); // else stop on frame 1
}

(For the last frame … say frame 10):

if (onMouseOut) // mouse moves away from area
{
gotoAndPlay(1); // play frame 1
}
else
{
stop(); // stop on the last animation frame
}

Does this sound reasonable? The only thing is, I don’t know what “onMouseOver” and “onMouseOut” for actionScript would be. Any help would be great. Thanks again!

-Bow-Nan

Invisible buttons are created by filling in only the hit spot frame of the button. So, create a square of fill on the stage.
select it and hit F8. Select button from the list and give it a name for the library. I usually use “buttonBlank”. Double click on it to edit it in place. Grab frame one, and drag it to frame four. You should see the first three frames empty, and a filled key frame on frame 4.

Create the movie clip with this in mind.
The animation that you want to come into effect for each situation, should have a stop action on it’s first frame, and last frame, but you can do it all on the timeline for the movie clip. This way, when you call it to play it will goto where ever, start playing, and finish at a state that you’re comfortable with. The last frame of the rollout animation should have the following action

gotoAndStop(1);

sending the playhead back to the beginning.

Give the movie clip and instance name. Open the instance panel with menu option “window/panel/instance”. go to your main timeline and then select the movie clip. The instance panel will show you that it is a movie clip, and what it’s “library” name is. In the blank field, give it an instance name. We’ll use “myMovieClip” for this example.

right click on the button, and in the pull down menu that apears, select “action”. This will open the action panel.
click once in the scripting area, and paste the following code.

on(rollOver){
myMovieClip.gotoAndPlay(2); // play frame 2
}

on(rollOut){
//frame 11, being whereever your next segment of animation begins
myMovieClip.gotoAndPlay(11);
}

with the button inside the movie clip, you could illiminate the “myMovieClip” and just use
gotoAndPlay();
in those instances.

For reference.
The action panel will let you add script to three places in a movie.
A) Frame actions are created by clicking on a frame in the timeline and entering script into the action panel.
B) Movie clip actions can be placed on movie clips by selecting them, and then entering text into the action panel.
the have many formats but some of the more common are shown here
onClipEvent(load){}
onClipEvent(data){}
onClipEvent(enterFrame){}
C) Button actions are created by selecting a button, and entering script into the action panel.
they have many formates but some of the more common are shown here
on(release){}
on(dragOver){}
on(rollOver){}
on(rollOut){}
on(press){}

note: most common mistake: most often newbies make the mistake of thinking that they have a movie clip or a button selected when in fact they do not. Keeping the instance panel open during action script creation is vital for keeping track of exactly what you have selected. After all, a button can be inside a movie clip. That same movie clip can be inside a group, a graphic, or another movie clip. etc. The point is, it can often look like you’ve selected something, when in fact you have not. :slight_smile:

note:about invisible buttons: One of the beutiful things about flash is that it loves to reuse things. A button which is a square of fill, but has no visual attributes takes up about .1k. If you were to use the same invisible button from the library, everywhere in your movie that you had button interaction, it wouldn’t matter how many times you did, the user would still only have to download 1 .1k object.
You are welcome to scale each instance of the blankButton to your particular need. It will not effect how the button reads “on mouse” methods. :slight_smile:

on(rollOver){
myMovieClip.gotoAndPlay(2); // play frame 2
}

Does this works like:

on(rollOver){
telltarget("/myMovieClip"){
gotoAndPlay(2);
}
}

You mean that I can use instancename.action; instead of telltarget???

If you do, then why this doesn’t work:
I have a button inside a movieclip. When I click that button, I want the main movie to gotoAndPlay(“scene_name”, 1);
But because that button is inside another MovieClip it doesn’t work…
So I tried doing this:

on(Release){
_root.gotoAndPlay(“scene_name”, 1);
}

But it doesn’t work either! What to do?

hehe… that’s an unrelated problem.

You are correct that it would be
_root.gotoAndPl…

the problem with that example is this.

When calling to scenes, you cannot use frame numbers. Try labeling the first frame of the second scene something like, “sceneTwoBegin”. Then in the button use it like this.

on(Release){
_root.gotoAndPlay(“sceneTwoBegin”);
}

The probelm is, when the movie is published, there aren’t mutiple scenes anymore. everything gets stacked end to end, and all the layers are colapsed. If the first scene had 20 frames, then in the final production, frame 21 is actually scene2 frame 1.

so use frame labels for movinging around as often as you can, it’s good practice anyway, as often we are called upon to add or subtract frames from our movies after we’ve done all sorts of work. If you’re using frame labels, then it never matters what you change, you’ll never have to go through and fix a bunch of tellTargets.