Flash CS3 Tutorial – Movie Clip Buttons
Flash Tutorial May 9th, 2008Many Flash beginners stick with using button symbols when creating navigation links for their Flash websites. And why not! That's what button symbols are made for, right?
Well, you can also create buttons using movie clip symbols. Movie clip buttons are basically buttons on steroids. With movie clip buttons, you have much more control over how your button behaves.
For example, when you're dealing with your button symbol's timeline, there's only so much you can do on the button's "over" state. If you want, you can stick a movie clip symbol within your button symbol's "over" state in order to add a little bit of animation, but what if you wanted a different animation to occur when you moved your mouse away from the button? There's not really a whole lot you could do there if you were using a simple button symbol.
So, in this tutorial, I'm going to show you how to make rollover and rollout animations on a movie clip button. For the sake of simplicity, we're going to create buttons that expand out sideways on rollover and animate back to their original size on rollout. So let's get started:
1. Create your movie clip button. For this example, create a simple rectangle with a piece of text centered on top of it. Here's what the graphics look like for my button:

Easy enough, right? Now, select your graphics, hit F8 to convert to a symbol, select Movie Clip and call it whatever you want. Even though this graphic is going to look and act like a button, we want to make it into a movie clip in order to take advantages of all the benefits of using a movie clip symbol. Finally, select your new movie clip button, and enter in an instance name for it in the properties inspector. I'm giving my button an instance name of btn_mc.
2. Enter your movie clip button's timeline. Double-click on your movie clip to go into the movie clip's timeline. In the movie clip's timeline, you're going to create a few different states for your button and then use frame labels to label these states.
3. Insert new layers into your movie clip button's timeline. Create a new layer called "Labels" and another new layer called "Actions." Keep these two layers at the top of your layer stack for easy access. Also, we need to separate the background of the button and the button text into separate layers. An easy way to do this is to select the Selection Tool in your toolbar, click once outside of your artwork to deselect everything (don't double-click, or it will take you back to the main timeline), then right-click on the background rectangle (or ctrl+click with a one-button mouse on a Mac) and click on "Distribute to layers." This will send the background rectangle to a new layer just below the current layer. Here's what your layer stack should look like now:

4. Create the "states" for your button. For this tutorial, we're going to create an up state, an over state, and an out state. The up state will contain the button at its default size and position, the over state will contain an animation of the button's background expanding to the right, and in the out state, it will animate back to its original size.
The up state will consist of a single frame and will reside in frame one, which we've already created. With frame one selected for the "Labels" layer, go to the Properties Inspector and type up into the frame label text field. For the over state, click on frame 10 for the "Labels" layer, hit F6 to add a new keyframe, and with this new keyframe selected, enter over into the frame label text field in the Properties Inspector. This frame (frame 10) will be the beginning of the rollover animation. You're going to make this 10 frames long, so the animation will end in frame 20. So, to add a little breathing room, jump over to frame 30 on the Labels layer, add a new keyframe, and label this one out. This animation will also take up 10 frames, so it will end in frame 40. Click on frame 40 for the Labels layer and hit F5 to extend the frames out so that you can read the final label in the timeline.
Now we need to add our stop actions. By default, a movie clip symbol will start playing through its timeline, and that's not what we want. By default, we want our movie clip button to stay in frame one until we hover over it. We also need to add stop actions to the end of our over animation and our out animation. So click on frame one, hit Option+F9 (or just F9 on PC) to open up your actions, and type stop(); into your actions panel. Then, close your actions panel.
We can easily copy this stop action to frames 20 and 40 by doing the following:
- Click on the keyframe in frame one of the Actions layer (where you just entered your stop action).
- With this keyframe selected, hold onto Option (or Alt on PC), click on the keyframe again, and drag to the right.
- Release the mouse button at frame 20, and you should see a new keyframe copied to frame 20 with the stop action applied to it.
- Perform steps 1-3 again, this time for the end of the out animation in frame 40.
The timeline for your movie clip symbol should now look like this:

5. Create the over and out animations. Since the text of the button isn't going to change, go ahead and click on frame 40 for the text layer and hit F5 to stretch the frames across the entire animation. Then, before you create the animation for the background of the button, select the rectangular background and convert it to a movie clip symbol. Call it whatever you like. (This symbol does not need an instance name.)
With your background converted to a movie clip, add keyframes to frame 10 and frame 20 of the background layer. Frame 10 will contain the beginning keyframe of the animation, and frame 20 will contain the ending keyframe of the animation.
Leave frame 10 alone. Click on frame 20, switch to the Free Transform Tool (keyboard shortcut: Q), and stretch the shape out to the right about 10 or 20 pixels (or as far as you'd like). If the shape stretches out in both directions when you try to resize the width, simply hold onto Option (or Alt on PC) while you drag it out, and the left edge will stay in place.
Right-click anywhere between frames 10 and 20 on the background layer and click on Create Motion Tween. The over state is now complete.
Click on frame 30 for the background layer (the beginning of the out state) and add a new keyframe. This new keyframe will retain the expanded size of the button. In this state, we want the button to animate back to its original size. To create the ending keyframe for this animation (since it needs to be the exact same size as it's starting size), right-click on frame 1 for the background layer, click on Copy Frames, then right-click on frame 40 and click on Paste Frames. Then right click between frame 30 and 40 and select Create Motion Tween. Your animations are now complete, and your timeline should look like this:

6. Return to the main timeline. At this point, we're done editing the movie clip button's timeline. Click on Scene 1 on the edit bar (the bar right below the timeline) to return to the main timeline.
7. Code your movie clip button. Create a new layer on the top of the layer stack in the main timeline and call this new layer Actions. Lock this layer by clicking on the layer underneath the padlock icon, click on frame 1 for the Actions layer, and hit Opt+F9 (F9 on PC) to open up your actions panel. Enter the following code into your actions:

Line 1 sets the buttonMode property of the movie clip to true. Without this, your button would still work, but the user would not see the hand cursor when they hovered the mouse cursor over the movie clip.
Line 2 sets up the event listener for the rollover. When the user rolls the mouse cursor over the button, this event triggers a function called onButtonOver, which we created starting on line 5. Inside this function, we're simply telling our button movie clip to go to the frame labeled over and start playing. It will then play until it reaches a stop action.
Line 3 sets up the rollout event listener, which triggers the onButtonOut function, which tells the movie clip to go to the frame labeled out.
Notice that there's nothing in this code that explicitly returns our movie clip to the up state. This is because it's really not necessary. The end of the out state looks exactly like the up state, so it really doesn't make a difference. But if we wanted to, we could have just left out the final stop action at the end of the movie clip timeline, and instead of stopping at frame 40, it would simply loop back to frame 1 where it encounters the stop action there. Doing this would result in the exact same visual result.
8. Bump up the frame rate. One last thing... For a nice, smooth animation, bump the frame rate up to 24 frames per second. This will give you a quicker, smoother animation. To do this, simply double-click on the frame rate displayed at the bottom of the timeline and enter in a new value.
Your final file should look something like this (I've added a few more buttons for demonstrative purposes):
Source file: mcButtons.zip


May 13th, 2008 at 3:10 am
This is a great tutorial and helpful for someone like me that is not very familyar with flash workflow!
Thank you for sharing it!
May 23rd, 2008 at 6:33 pm
Thanks very helpful
I would love it if you could go onto the next step and explain how you play a certain frame label with that script.
May 30th, 2008 at 10:34 pm
great tutorial! finally sumthing that works.
one question though. im creating a total of 4 buttons in a single flash file. however it doesnt work. it gives me a “1021 duplicate function defintion” error. Pls help. Thanks!!
June 2nd, 2008 at 9:43 pm
girl–> i think that’s what he did show you. The example he uses, uses the frame labels ‘over’ and ‘out’. If you want to play a frame label in a different scene:
gotoAndPlay(’scene’,'label’);
or in a different movie clip:
nameofMovieClip.gotoAndPlay(‘label’);
you would substitute these in the lines where he has:
e.currentTarget.gotoAndPlay(‘over’);
June 8th, 2008 at 9:40 pm
Thanks for the tutorial, it worked great. My buttons start off partially covered by higher layers. When the mouse hovers, they slide (actually move) to the right, displaying additional writing on the button.
A problem that I’m having is that the part of the button that is hidden from view by the upper layers, still triggers the roll over event. Is there a way to have these events only work on the visible portion of the button?
Thanks.
June 8th, 2008 at 9:53 pm
Two minutes later, I figured out a way to fix my problem. I converted an upper layer object into a movie clip. Gave it an instance name. Added an event listener for mouse over and pointed it to a function that doesn’t do anything.
Although this works fine, it doesn’t seem to the best solution. There is probably a property that I’m missing.
June 12th, 2008 at 11:49 am
how do i put this into a dreamweaver site?
June 17th, 2008 at 4:54 pm
i think what red_raider says not make any sense, doesnt work like that, you need to create another function inside de same code, function who make an action when you click the button…
June 22nd, 2008 at 5:11 pm
Sooo…still new to all this. If I wanted to have each of these buttons link to a different web page within a web site, how do I tell it to do that?
July 7th, 2008 at 10:41 pm
how can I add an active state to my btns in addition to this code?
Thx!
July 17th, 2008 at 8:01 pm
“great tutorial! finally sumthing that works.
one question though. im creating a total of 4 buttons in a single flash file. however it doesnt work. it gives me a “1021 duplicate function defintion” error. Pls help. Thanks!!”
I also want to know how you are able to have multiple buttons in the flash
July 18th, 2008 at 10:47 am
Hello great tutorial!
I have a small problem though — im using actionscript 2 and the following line pops out an error when i run the script:
function onButtonOver(e:MouseEvent):void
Any ideas on how i could convert that to work with actionscript 2? thanks
July 25th, 2008 at 3:58 pm
Hello
Great writeup, very helpful.
I have a question, hopefully you can help me with it.
I have a button within a movie clip. Well say home_btn. the clip is menu_mc. What is the proper way to assign an onRelease event to it? Currently I have
menu_mc.home_btn.onRelease = function() {
loadmovie(“test.swf”);
}
This isn’t working at all, care to shed some light?
Thanks.
August 5th, 2008 at 8:56 am
Thank you Craig, wonderful tutorial. Helped me fix a few buttons on my upcoming site that were getting stuck. The actionscript is simple and effective.
August 5th, 2008 at 10:17 am
So….how come there is no talk on how to link buttons to a url?
August 28th, 2008 at 3:36 pm
[...] Skapa knappar med MovieClips, länk [...]
August 30th, 2008 at 4:25 pm
[...] For the most part, the button symbol has gone the way of the dodo for many Flash developers. Because movie clip symbols are so much more flexible than button symbols, most developers have completely stopped using button symbols. Instead, they opt to use movie clip symbols AS buttons. [...]
September 1st, 2008 at 8:45 pm
Thanks, Craig! I’ve never used any code before ever, and was still able to apply this tut to a route map project I’m working on. A real lifesaver, please post more like this!
September 2nd, 2008 at 8:44 pm
I keep receiving the following errors, and have gone over and over the code but still do not see where the errors are, any help will be great
Error 1,
Location:
Symbol ‘btn_mc’, Layer ‘action’, Frame 40; line 1
Description:
1120: Access of undefined property btn_mc.
Source:
btn_mc.buttonMode = true;
Error 2;
Location:
Symbol ‘btn_mc’, Layer ‘action’, Frame 40; line 2
Description:
1120: Access of undefined property btn_mc.
Source:
btn_mc.addEventListener(MouseEvent.ROLL_OVER,onButtonOver);
Error 3;
Location:
Symbol ‘btn_mc’, Layer ‘action’, Frame 40; line 1
Description:
1120: Access of undefined property btn_mc.
Source:
btn_mc.addEventListener(MouseEvent.ROLL_OUT,onButtonOut);
September 6th, 2008 at 11:36 pm
how can u make a new untouched movieClip with nothing with it or in it plz reply anyone
September 9th, 2008 at 9:51 am
unknown : apple-F8
September 14th, 2008 at 7:58 pm
Craig, cmon please show us how to add both a ‘goto and play (frame label) On CLick action’ so this could be used in practise on a say a flash portfolio page – and a ‘get url action’ to this as this is where all the interest in getting this to work – and then the tutorial is complete – by having on rollover /rollout movie clip animations working it is more confusing trying to understand how to add this – I have tried adding this in the same part of the actionscript and it doesn’t seem to work…
Would be great if you can add these as I have made some nice rollover/ rollout animated movie clip buttons but cannot take it to the next stage, best
Bill
September 23rd, 2008 at 4:05 pm
Thank you So much for a great tuttorial…
nice and simple and so beautiful… LOL!
September 24th, 2008 at 3:14 am
Javier try this…
I think u should add addEvenListener() to your movie clip;
like this:-
menu_mc.home_btn.addEventListener(MouseEvent.CLICK, onclick, flase, 0, true);
function onclick(evat:MouseEvent):void
{
loadmovie(”test.swf”);
}
i’m not sure but i think it’ll be work.
September 28th, 2008 at 7:28 am
ok Javier this might seem a bit late but hopefully it will help others with the same problem of creating multiple buttons.
When you are on the main stage press on your button layer(the one under Actions) then convert that into a Symbol (movie clip). Then copy the actions layer on the main stage, double click your new movie clip and just past the action layer on top of layer1. Now when you exit and go back onto the main stage delete the actions layer so you just have one layer.
Now you just drag and drop or duplicate you new movie clip and there shouldnt be a prblem.
cheers
Peter
October 9th, 2008 at 7:08 am
This is exactly the effect i needed to achieve. And I’ve been messing around with Buttons for ages!
October 15th, 2008 at 9:17 am
hello, very nice tutorial, but as I am not an advanced developer, I wonder how or where to trigger the ‘getUrl’ function on each mc-button? Thanks beforehand,
Frank
October 22nd, 2008 at 12:39 pm
How do I make buttons work with the arrows on my keyboard? I want people to be able to advance in my gallery by clicking the right arrow and go back by clicking the left. I’m using actionscript 2 in CS3
Thanks
November 2nd, 2008 at 9:52 pm
Hello, I’m having a little trouble with the actionscript.
the following errors are appearing.
**Error** Scene=Scene 1, layer=Actions, frame=1:Line 5: The class or interface ‘MouseEvent’ could not be loaded.
function onButtonOver(e:MouseEvent):void
**Error** Scene=Scene 1, layer=Actions, frame=1:Line 9: The class or interface ‘MouseEvent’ could not be loaded.
function onButtonOut(e:MouseEvent):void
Total ActionScript Errors: 2 Reported Errors: 2
using actionscript 2. thanks
November 5th, 2008 at 12:27 pm
Wow – I love it when a Flash tutorial is clear enough for even a beginner like me to gain knowledge from it. I’m SO grateful I found this – thank you very much!
November 11th, 2008 at 1:32 am
Hi everybody,
i am new to cs3. i have one small problem. when i am using cs2 , iam using eval to concordinate number with movie clip.
Now i am using cs3 there is no option eval. please help me
in flash as2 i write some code.
same code i need in cs3.
for(i=1;i<=5;i++){
eval(“a”+i).onRelease=function(){
trace(this._name)
}
i have button movieclip on the stage.like a1,a2,a3,a4,a5
please help me
}
November 12th, 2008 at 8:29 am
Excelent example for button, but work for container for list? move on, mouse over start animation ?
November 19th, 2008 at 7:40 am
Wow .. Excellent example , thank you Craing,God bless you..
November 20th, 2008 at 12:26 pm
Thanks, Craig. Been a fan for a long time.
By the way can someone suggest how to string 7 movie clips into one? So they play consecutively and loop. I can do it as one big messy movie but am trying to take advantage on mcs as Craig has promoted.
December 2nd, 2008 at 11:51 am
Excellent tutorial! Thanks so much. It helped me solve the issues I was having with actionscript 1.0 and 2.0.
Addressing some questions in the comments:
This will only work for actionscript 3.0.
Here’s altered code on how to go to a website on click:
instanceName.buttonMode = true;
instanceName.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
instanceName.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
instanceName.addEventListener(MouseEvent.CLICK, onClick);
function onButtonOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay(“over”);
}
function onButtonOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay(“out”);
}
function onClick(e:MouseEvent):void
{
var url:String = “http://www.website.com”;
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, ‘_blank’);
} catch (e:Error) {
trace(“Error occurred!”);
}
}
For use with multiple buttons within your Flash project, simply duplicate the first 4 lines and change the instance names to match the names of each button.
December 11th, 2008 at 1:33 pm
Big thanks for this.. and to kim fenolio for the link code too. I’ve adapted it slightly, you’ll see it in action here…
http://www.intelengineering.co.uk
December 16th, 2008 at 9:21 pm
Hi,
I have a problem with movie button information using flash CS3 AS2. I have two movie buttons on one frame, each movie button has a simple code, obviously the frame #is different per button:
on (release) {
gotoAndStop(2);
}
when pressed brings up 3 sub-buttons, each of those buttons have the same code set-up:
on (release) {
gotoAndStop(2);
}
bringing it to that time line frame with an image.
(its very simple, one image per frame).
But when i press the second movie button that has the same set-up as the first, the first button still displays an image. So it ends up being info on info. I need the first movie button to return to frame 1, when movie button 2 is pressed…
If you have a simple code that you could pass on to me, I’ve been looking everywere, if anyone knows please share. – Thanks
December 18th, 2008 at 3:54 am
Nice and simpel code
works fine here thx
January 4th, 2009 at 5:30 am
THANKS aLOT
January 5th, 2009 at 4:24 am
I made a set of buttons using this method, but when i drag the pointer fast over a few buttons (in one drag) then my over state stays visible. When i put the pointer over the buttons again they are working in reverse order (over = out and out = over).
Why is that?
January 10th, 2009 at 5:15 pm
I would like to know
1 = how you can disable the button once it’s clicked, so it can’t be clicked again until another button is clicked.
2 = once it’s clicked it should stay at the over position and when you rollOut of it, it shouln’t rollOut until another button is clicked.
Can anyone help with that ??????
Thanks…
January 11th, 2009 at 9:53 am
Thanks for the tutorial!
I want to add a click funtion (target= specific frame on the main scene timeline) to the Actions of the button.
When I add:
btn_sydney.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay(frame#);
}
1. it does not work
2. when I test the movie the buttons are all in the “running mode” (read: they are all looping their individual button-movie).
Can anybody help me on this?
Thanks and regards,
Floran
January 15th, 2009 at 8:54 am
Anyone know how i can link each button to a website now? i keep getting errors.
January 27th, 2009 at 11:58 am
Hey Matt,
Your problem is instance names. You need to ‘define’ the button by highlighting it on its layer, and naming it in the properties panel (usually below the stage). In this case, the name is btn_mc
January 29th, 2009 at 1:57 pm
Excellent tutorial Craig.
As for the people who does no understand the action Script part, there is a way to create buttons on Flash CS3 (below??) without having to use a line of code
on your flash document go to the library (CTRL+L)then you are going to have to find the add new symbol option, if you dont know how it looks its a small square with a + sign.
Click in the add new symbol button and select what do you want it to be, a movie clip, a graphic or a button…you know the obvious answer..select button then flash is going to take you inside the scene and if you look at your timeline you should get 3 options: Up, Over, Down and hit, draw your button on each timeline option then go back to the scene , now the only thing left is the hyperlinks, well…just put some text over the button and add the hyperlink on the properties panel……..thats it, now you have animated buttons with no action script involved.
February 3rd, 2009 at 3:34 am
hi i am vipin sharma thanx for this tutorials
February 4th, 2009 at 5:47 pm
i have to say a big THANK YOU for this wonderful tutorial! revisiting the software from the old MX days, i see so much has changed. thanks for helping me get my feet wet again and for this really informative How-To.
February 11th, 2009 at 2:33 am
No workie for me, web is full of crap.
February 14th, 2009 at 4:03 pm
great stuff. Any ideas on where to get a tutorial for the conditional statements so on mouse out it plays from the current frame instead of jumping to the end and then playing backwards? Thanks!!
February 15th, 2009 at 4:44 pm
“Hello, I’m having a little trouble with the actionscript.
the following errors are appearing.
**Error** Scene=Scene 1, layer=Actions, frame=1:Line 5: The class or interface ‘MouseEvent’ could not be loaded.
function onButtonOver(e:MouseEvent):void
**Error** Scene=Scene 1, layer=Actions, frame=1:Line 9: The class or interface ‘MouseEvent’ could not be loaded.
function onButtonOut(e:MouseEvent):void
Total ActionScript Errors: 2 Reported Errors: 2
using actionscript 2. thanks”
Hi, i’m having the same problem, have anyone solved it?
February 19th, 2009 at 3:50 pm
Your tutorial helped me create the buttons on this site http://www.sullivancenter.com.
Now I have a new challenge. I’ve have a row of images that are about 88×88 pixels large. When the user hovers over an image, it enlarges to about 200×200. I’m able to get that working great.
The problem is that I want the other images to get smaller or move over when one of the images is enlarging – to make room.
Using your tutorial as an example, when you hover over Button 1 it not only gets bigger but Buttons 2, 3 and 4 get smaller. Conversely, upon MouseOut of Button 1, it shrinks back to normal size and Buttons 2, 3 and 4 return to their original position.
Thanks for any advice!
February 26th, 2009 at 11:25 pm
Thanks for the effort, though not working for me. I’m getting these errors:
**Error** Scene=Scene 1, layer=actions, frame=1:Line 5: The class or interface ‘MouseEvent’ could not be loaded.
function onButtonOver(e:MouseEvent):void
**Error** Scene=Scene 1, layer=actions, frame=1:Line 10: The class or interface ‘MouseEvent’ could not be loaded.
function onButtonOut(e:MouseEvent):void
**Error** Symbol=aboutmovbutton, layer=Actions, frame=1:Line 5: The class or interface ‘MouseEvent’ could not be loaded.
function onButtonOver(e:MouseEvent):void
**Error** Symbol=aboutmovbutton, layer=Actions, frame=1:Line 10: The class or interface ‘MouseEvent’ could not be loaded.
function onButtonOut(e:MouseEvent):void
Total ActionScript Errors: 4 Reported Errors: 4
Also, when I enter your code these don’t show up in blue:
MouseEvent.ROLL_OVER
MouseEvent.ROLL_OUT
currentTarget
currentTarget
Please let me know what I’m doing wrong.
Thanks in advance!
February 27th, 2009 at 7:40 am
Cipriano: Are you using ActionScript 2 or 3? The code for this tutorial is in ActionScript 3.
February 28th, 2009 at 10:45 pm
Thanks Craig!
Yes I’m on AS2 which explains it.
For those on AS2 I used the following code to substitute the code in this tutorial and it seems to work fine:
this.btn_mc.onRollOver = function() {
about_but_mc.gotoAndPlay(“_over”);
};
this.btn_mc.onRollOut = function() {
about_but_mc.gotoAndPlay(“_out”);
};
Aloha to all!
February 28th, 2009 at 10:50 pm
Oops -correction. I used this code:
this.btn_mc.onRollOver = function() {
btn_mc.gotoAndPlay(“over”);
};
this.btn_mc.onRollOut = function() {
btn_mc.gotoAndPlay(“out”);
};
So Sorry
March 3rd, 2009 at 3:19 am
hi Craig!
First of all Thanks for the great tutorials!
would you be so kind as you help me how to >>Stick movie clip buttons<< to different pages of the website?
here is my code, but somethingis wrong:
var btnArray:Array = [alapCircle.btnmagam , alapCircle.btngal, alapCircle.btnkapcs,alapCircle.btnlink];
for (var i:int = 0; i< btnArray.length; i++){
btnArray[i].mouseChildren = false;
btnArray[i].buttonMode=true;
btnArray[i].addEventListener(MouseEvent.ROLL_OVER, onrollover);
btnArray[i].addEventListener(MouseEvent.ROLL_OUT, onrollout);
btnArray[i].addEventListener(MouseEvent.CLICK, onclick);
}
function onrollover (event:MouseEvent):void {
if(currentPage != event.currentTarget){
event.currentTarget.gotoAndPlay(“_over”);
}
}
function onrollout (event:MouseEvent):void{
if(currentPage != event.currentTarget){
event.currentTarget.gotoAndPlay(“_out”);
}
}
function onclick(event:MouseEvent):void {
if (currentPage != event.currentTarget){
currentPage.gotoAndPlay(“_out”);
}
currentPage = event.currentTarget;
event.currentTarget.gotoAndStop(“_down”);
}
(all the buttons are in a main movie clip called alapCircle, and each one has 4 state)
Thanks in advance for any advice!
Andicska
March 4th, 2009 at 4:11 am
Hi again !
I just write to told you i fixed the problem
voltmar is a boolean variable, which is false, until i have visited a page.
function onclick(event:MouseEvent):void {
if (currentPage != event.currentTarget && voltmar){
currentPage.gotoAndPlay(“_out”);
//ez itt nem fut le úgy hogy null objeck reference van.
}
voltmar=true;
currentPage = MovieClip(event.currentTarget);
//trace(currentPage)
event.currentTarget.gotoAndStop(“_down”);
}
Have a nice day
March 5th, 2009 at 3:58 pm
Hi, i have a little problem. The button is working fine, but how can i do to go to another scene or a different frame on the same scene after pushing the button?
March 12th, 2009 at 6:07 pm
Could the the technique described in this tutorial have been used to create the effect of the “portfolio” page of the following website?
http://ashleyannphotography.com/index2.php?v=v1
I really like the navigation on this site, but I can’t figure out how they did it…
March 22nd, 2009 at 2:56 am
Thanks Craig for another helpful tutorial.
Also, thanks Cipriano for the Actionscript 2.0 code. I was receiveing that error message as well, and initially concluded it was a due to a conflict between PC and MAC.
The button works well…Now I have to figure out how to link it to a url and trigger pages/timeline…
Anyone have a clue (using AS2.0)?
March 30th, 2009 at 10:22 am
So how do you link these buttons to URLs?
April 6th, 2009 at 6:14 am
same question like wrensch820
April 6th, 2009 at 6:55 am
the answer? (it works)
add to the code:
btn1_mc.addEventListener(MouseEvent.CLICK,myClick1);
function myClick1(event:MouseEvent):void {
var request:URLRequest = new URLRequest(“http://www.google.de”);
navigateToURL(request);
}
btn2_mc.addEventListener(MouseEvent.CLICK,myClick2);
function myClick2(event:MouseEvent):void {
var request:URLRequest = new URLRequest(“http://www.google.de”);
navigateToURL(request);
}
btn3_mc.addEventListener(MouseEvent.CLICK,myClick3);
function myClick3(event:MouseEvent):void {
var request:URLRequest = new URLRequest(“http://www.google.de”);
navigateToURL(request);
}
btn4_mc.addEventListener(MouseEvent.CLICK,myClick4);
function myClick4(event:MouseEvent):void {
var request:URLRequest = new URLRequest(“http://www.google.de”);
navigateToURL(request);
}
btn5_mc.addEventListener(MouseEvent.CLICK,myClick5);
function myClick5(event:MouseEvent):void {
var request:URLRequest = new URLRequest(“http://www.google.de”);
navigateToURL(request);
}
btn6_mc.addEventListener(MouseEvent.CLICK,myClick6);
function myClick6(event:MouseEvent):void {
var request:URLRequest = new URLRequest(“http://www.google.de”);
navigateToURL(request);
}
April 7th, 2009 at 1:33 pm
http://www.sullivanceter.com was not designed developed or touched by Richie. I know for sure, because we did it. Richie a suggestion, DONT TAKE CREDIT FOR SOMEONE ELSE’S WORK.
April 9th, 2009 at 4:31 am
These are really cool buttons.
But I was wondering, you could get each of those buttons to change color or shape when to click on it, and for that button to stay like that to show that button has been pressed.
The trouble is, how would it stay like that when you rollover?
Also, to create extra problems for yourself, when you click on one button, and glows (animated), and stays glowing to show thats the button you’ve pressed; How would you then say in the action script 3 when I press on another button, have the previous button play a de-select sequence, whilst the current button plays the selected sequence?
Help in this matter would be great
Rusty
April 22nd, 2009 at 9:58 am
Hi,
Once I bring my movie symbol containing the buttons.
I would like to link these buttons to the a frame in main stage in my fla file. Is it possible?
thanks and a quick respond will be appreciated.
May 3rd, 2009 at 10:13 am
Hi, i have just come accross this example, and i’m sorry but i must say that it’s not that good.. From an OOP point of view, puting the code logic of the button in the main timeline breaks the encapsulation, this code should be at least in the button frame 1 (or better in a separate class for a generic button). And this code will also have to be repeated for every button on the stage…
-lucas
May 4th, 2009 at 3:52 pm
hi sorry but this isn’t working for me I also use Flash CS3 and after I type in the code a little pop up thing came up and told me there is an error in line 5 and line 10 of the code but i’m pretty sure i typed in it right, please help! Thanks
May 13th, 2009 at 12:50 am
hi im a newbie with flash cs3. and i cant make my movie clip clickable. what is the exact code for it?! im using activescript by the way..
thanks!
May 26th, 2009 at 8:11 pm
I am trying to have each button move to each a different scene when on click, but it is not working. Can someone please post the script for it? Thanks!
May 28th, 2009 at 10:38 am
Fantastic tutorial- thank you for sharing your expertise with the world- combining this tutorial with others allowed me to exactly what I needed!
Craig- you rock!
May 31st, 2009 at 5:16 pm
-> Andicska Make sure that Actions Frames with stop(); cmd. lIne are not matching with those from the Labels line
June 1st, 2009 at 10:31 am
Many Thanks, a nice simply tutorial that could be combined with other techniques to make some interesting animations.
June 1st, 2009 at 10:09 pm
Very useful tutorial (and subsequent helpful pointers), thanks all!
July 23rd, 2009 at 8:34 am
import fl.transitions.Tween;
import fl.transitions.easing.*;
function markerfollow(event:MouseEvent):void
{
var myTweenWidth:Tween = new Tween(btn, “width”, Strong.easeOut, btn.width, btn.width + 30, 3, true);
}
function markerfollow2(event:MouseEvent):void
{
var myTweenWidth2:Tween = new Tween(btn, “width”, Strong.easeOut, btn.width, btn.width – 30, 3, true);
}
btn.addEventListener(MouseEvent.ROLL_OVER, markerfollow);
btn.addEventListener(MouseEvent.ROLL_OUT, markerfollow2);
July 24th, 2009 at 1:19 pm
Over a year ago MATT addressed my issue but I don’t understand his solution. I have small square button, On rollover an image flys out and holds on screen but now the whole area is active and I just want the small square to remain active. Hit area doesn’t help. I’ve tried making a hit area only button…doesn’t work, I’ve tried hitArea code, doesn’t work.
September 2nd, 2009 at 12:46 pm
Thanks, Craig! From the sounds of it, this advice will save me lots of extra leg-work over the long term, plus allow me to do a lot more with the buttons. Cheers!
September 9th, 2009 at 4:26 am
evening….
my prob is that the button in the movie clip doesnt connect in the scene…
i mean i drag the movie clip in frame1 for example and the button in it suppose to trigger another frame to load (it will go to another frame) but it didnt. this is my code in the movie clip button:
on(press){
gotoAndStop(2);
}
what should i do??? plz reply asap…
September 13th, 2009 at 6:27 am
Hi,
basically my problem is that, i have made all my buttons by movie clips, and all the different pages by movie clips, but i have movie clip buttons, inside those movie clip pages, and cannot figure out how to make these movie buttons inside the movie clip work to go to the next page.
can anybody help me please?!
September 24th, 2009 at 2:59 pm
I stumbled on this Button tutorial and it solved most of my problem, a really great tute. I’d like to take this button menu one step further so please if anyone can help I’d appreciate it. I’d like to know how to get the button to stick in the stretched position when you click it to go to a new web page. I have Craig Campbell’s tutorial Building a Website in Flash 8 that makes this work but I am now using Flash CS4 and Actionscript 3.0 so the code needs to be different. I think I need to add a new label “down” at frame 20 on the labels layer and add some new code with an “if” statement. Please Help.
October 12th, 2009 at 4:28 pm
Hallo everyone..
I am wondering if any of you would be so kind to assist in extending this tutorial with guidance on how to do the following:
I have two buttons in frame one (Phase 1 and Phase 2)- these are movieclip buttons.
When the user clicks on any of the Phase buttons a submenu is displayed on the left. The user clicks on this to reveal information about the specific components of the course. What I need help with is the following:
The movie clip button should have 4 states:
Up, over, busy(down) and (up and over is no problem)
Each of these states has a different image. When the user clicks on for eg Phase 1 button, the busy (down) state image should stay visible on screen and does not return to the up state unless they exit the program.
When the user then clicks on the next button for eg Phase 2, the state of the Phase 1 button should change to the complete state image. The same applies for the buttons in submenus of each of the phases. A further challenge (for me in any case) is that they do not have to click on the buttons in a specific sequence.
Your help will be much appreciated. (I use Flash CS3.)
October 12th, 2009 at 4:30 pm
With reference to my previous post – the fourth state of the button is complete. Sorry about that
October 15th, 2009 at 7:30 am
Hi,
Am trying trying to get this code to work but can’t figure it out. I want the button to open a new URL / window, but am getting Syntax Errors.
Any help greatly appreciated.
CS4 – AS3
btn_i.buttonMode = true;
//btn_i.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
//btn_i.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
btn_i.addEventListener(MouseEvent.CLICK, myClick1);
function myClick1(e:MouseEvent):void
{
var url:String = “http://www.google.com”;
var request:URLRequest = new URLRequest(url);
try {
navigateToURL(request, ‘_blank’);
} catch (e:Error) {
trace(”Error occurred!”);
}
}
October 15th, 2009 at 7:36 am
Hi,
Ok, got it to work.
FYI:
btn_i.buttonMode = true;
//btn_i.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
//btn_i.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
btn_i.addEventListener(MouseEvent.CLICK, myClick1);
btn_i.addEventListener(MouseEvent.CLICK, myClick1);
function myClick1(event:MouseEvent):void {
navigateToURL(new URLRequest(“http://www.google.com/”));
}
November 5th, 2009 at 2:01 am
Hi.
It’s a great tutorial you got here. I’m having a bit of trouble with my buttons. I used an imported PSD file for a button image, and everything is smooth. Is there any way I I duplicate the button properties(actionscript, states e.t.c.) but use a different image instead?
I’m still new at flash so any help at all is much appreciated. =P
November 21st, 2009 at 3:30 am
hi its really good… but i have a problem in this script
that when i over the button and click..go to the page and play but when mouse come out side the button without click that page gone so i need when i come out button still i want click state image….
pls help me
btn1_mc.buttonMode = true;
btn2_mc.buttonMode = true;
btn3_mc.buttonMode = true;
btn4_mc.buttonMode = true;
btn1_mc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
btn1_mc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
btn1_mc.addEventListener(MouseEvent.CLICK, onClick);
btn2_mc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
btn2_mc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
btn2_mc.addEventListener(MouseEvent.CLICK, onClick);
btn3_mc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
btn3_mc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
btn3_mc.addEventListener(MouseEvent.CLICK, onClick);
btn4_mc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
btn4_mc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
btn4_mc.addEventListener(MouseEvent.CLICK, onClick);
btn5_mc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
btn5_mc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
btn5_mc.addEventListener(MouseEvent.CLICK, onClick);
btn6_mc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
btn6_mc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
btn6_mc.addEventListener(MouseEvent.CLICK, onClick);
btn7_mc.addEventListener(MouseEvent.ROLL_OVER, onButtonOver);
btn7_mc.addEventListener(MouseEvent.ROLL_OUT, onButtonOut);
btn7_mc.addEventListener(MouseEvent.CLICK, onClick);
function onButtonOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay(“over”);
}
function onButtonOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay(“out”);
}
function onClick(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay(“Release”);
}
December 30th, 2009 at 4:51 pm
Great tutorial…
My website http://www.8minutecreditapproval.com.php5-9.dfw1-1.websitetestlink.com/home-animated.html where each check box is a separate movie clip with button features as per the tutorial above…
Two questions:
One: How do I get the separate movie clips (Check Boxes with text) to only show once and not repeat the “up” and “over” sequences… I want to be able to select the check box and move onto the second check box then the third…
Two: How do I set the third movie clip check box so that when I click it goes to a new scene…
any help would be greatly appreciated…
Marcus
January 21st, 2010 at 1:06 pm
hi its really good… but i have a problem in this script
that when i over the button and click, not open the page i want open url page..
please help me…
_root.link = _root.button;
_root.myMenu["but" + _root.link].gotoAndPlay(“s1″);
2nd code…
on (rollOver)
{
if (_root.link != num)
{
gotoAndPlay(“s1″);
} // end if
}
on (releaseOutside, rollOut)
{
if (_root.link != num)
{
gotoAndPlay(“s2″);
} // end if
}
on (release)
{
_root.butF(num);
}
January 25th, 2010 at 4:42 pm
You’ve written nice post, I am gonna bookmark this page, thanks for info.
February 23rd, 2010 at 10:02 pm
This is a great tutorial and my buttons work very well except for one thing. They link to other pages within my website, but will only open up in a new tab or window. Can someone help me figure out how to make the links open up in the same window? Thanks so much!!
February 27th, 2010 at 2:09 pm
Just wanted to thank you A LOT for this tutorial. I’m pretty new to AS3 and I’ve spent at least 3 hours of searching to find this. I’m not the type that posts comments to tutorials and such, so this will be my first =) Take it as a big compliment, thanks!
March 11th, 2010 at 6:12 pm
I cannot get this code to work. I remade this button 4 times and keep getting an error. I’m working in Action 2.0. could that be the problem. VERY FRUSTRATING!
March 11th, 2010 at 6:14 pm
Here.s my code. I put it on Frame 1 in Scene 1. The instance name was put in the nested movie clip.
Here’s my code.
What the heck did I do wrong?
btn_mc.buttonMode=true;
btn_mc.addEventListener(MouseEvent.ROLL_OVER,onButtonOver);
btn_mc.addEventListener(MouseEvent.ROLL_OUT,onButtonOut);
function onButtonOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay(“over”);
}
function onButtonOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay(“out”);
}
March 14th, 2010 at 11:28 am
how to do this in flash AS2.0? pls help.. thanks
March 20th, 2010 at 10:05 pm
hi, im not very good with flash at all and i need to know whether it is possible to make a button appear halfway through the animation. when this button is pressed, it should take you to the last frame and play….if it is not pressed it should stop 3/4 of the way through and stop there…i dont know if that makes sense but is anything like this possible?