In this tutorial, I will teach you how to create complex rollover button using actionscript 3.0.
Download Source Files




stop();
var rewind:Boolean = false;
myBT.addEventListener(MouseEvent.ROLL_OVER,growUP);
myBT.addEventListener(MouseEvent.ROLL_OUT,growDown);
myBT.addEventListener(MouseEvent.CLICK,gotoSite);
myBT.buttonMode = true;
myBT.useHandCursor = true;
function growUP(e:MouseEvent):void{
play();
rewind = false;
}
function growDown(e:MouseEvent):void{
rewind = true;
}
function gotoSite(e:MouseEvent):void{
navigateToURL(new URLRequest("http://www.getw3help.com"),"_blank");
}
this.addEventListener(Event.ENTER_FRAME,revFrame);
function revFrame(e:Event):void{
if(rewind == true){
prevFrame();
}
}
var rewind:Boolean = false;
myBT.addEventListener(MouseEvent.ROLL_OVER,growUP);
myBT.addEventListener(MouseEvent.ROLL_OUT,growDown);
myBT.addEventListener(MouseEvent.CLICK,gotoSite);
myBT.buttonMode = true;
myBT.useHandCursor = true;
function growUP(e:MouseEvent):void{
play();
rewind = false;
}
function growDown(e:MouseEvent):void{
rewind = true;
}
function gotoSite(e:MouseEvent):void{
trace("hello");
navigateToURL(new URLRequest("http://www.getw3help.com"));
}
this.addEventListener(Event.ENTER_FRAME,revFrame);
function revFrame(e:Event):void{
if(rewind == true){
prevFrame();
}
}
Labels: ActionScript 3, Flash
This is a great tutorial! The only thing I'm missing is how to use this in the context of multiple animated buttons. The project I'm working on requires 4 buttons on the stage. How do I implement this interaction in that way?
Thanks!
By JonCole, at October 23, 2008 7:14 AM
hi joncole,
Its easy, create a new movieclip, copy and paste these frames in that movieclip. Similarly for other 3 buttons too..
By makubex, at October 25, 2008 3:09 AM
Thank you!! This tutorial helped me so much! I have been trying to figure out how to do this for a long time now and finally I have the answer!
By NIKLOKE, at November 9, 2008 6:41 AM
The code Explanation "When the movieclip is rolled out, we assign rewind as false." is wrong.
Rewind should be True as this moment.
By Hermus, at November 13, 2008 12:58 AM
Amazing tutorial, made very simple for newbies like me.
My only problem, is when I have copy and pasted the movie clip buttons to my site, I dont know where to add script to navigate the buttons to frame labelled sections on my main stage...
I have tried adding it to the original script from the tutorial, but replacing go to site with appropriate script, but no luck :(
If anyone could tell me where I am going wrong, it would be very much appreciated!
Thanks in advance for any help!
By radium, at January 27, 2009 11:43 AM
Hey !
That's cool but i think the easiest way to do that is to use _frame properties of tweener
By Poilane, at February 2, 2009 6:45 AM
Great Tutorial! Exactly that, what I needed!
But with one thing, I need your help:
It would be perfect, if you'd have the whole tween and scripts not in the scene1 but in the movieclip (e.g. 'myCircle').
The advantage would be that you could add more than one Button to a bigger project (like a homepage), where the frames of scene1 are needed for a preloader and the single pages...
That would also solve the problem of radium.
So, I hope, that you can help me (I'm new at Flash and so it'd take a lot of time, to trie to do this at my own)
By Pascal, at February 2, 2009 10:01 AM
Help Please!!! I am getting my butt kicked by this. I am a newbie in actionscript so i am sure this will help me to better understand lots of things .... I am trying to play 3+ buttons in my movie and I can not make it work. I am able to get all the buttons to function at the same time but not as they are supposed to... 1 at a time.
Makubex you said "Its easy, create a new movieclip, copy and paste these frames in that movieclip. Similarly for other 3 buttons too.." << This ain't working for me can you please break this down just a little further for me please.
By tattoosnme, at July 5, 2009 6:15 PM
Okay ... the lights are on and I am now home. I figured it out. Call me Dangerous.
Thank you this tutorial is great!
By tattoosnme, at July 6, 2009 5:45 AM
hello, i have used your code and it works great :)
however, i would like to be able to use motion XML instead of the actual timeline to create the tween, and achieve the same results. is this possible?
By prycey, at November 5, 2009 10:29 AM
Wow, I cannot get this to work for the life of me...anyone have any idea why???
By rit, at November 29, 2009 12:30 AM
Nevermind, I figured it out. For some reason I couldn't just copy the code in the page...I had to use the code from the source file.
How do you do the same effect but with multiple buttons? I tried creating a new movieclip with a different instance name and then added a few lines of code but it didn't seem to work too good. Anyone figure this out?
Thanks for posting this script btw...I've been trying to figure this out for hours!
By rit, at November 29, 2009 1:37 AM
navigateToURL(new URLRequest("http://www.getw3help.com","_blank"));
There's an error in this line. The correct syntax is:
navigateToURL(new URLRequest("http://www.getw3help.com"),"_blank");
Cheers,
Elias
By Elias, at December 7, 2009 2:32 PM
...Sorry, i forgot: but thanks for the great tutorial ;) Very helpful for me!
By Elias, at December 7, 2009 2:33 PM
amazing tutorial, I used it on 11 buttons in my project and is working well.
Really spectacular
thanks
By Pedro, at December 12, 2009 6:09 AM
Hi -
I successfully completed my own version of this tutorial - but I also have the same problem as others - I can't seem to make multiple buttons work separately...
I do not understand the following thread from makubex here below that instructs how to solve this
makubex:"Its easy, create a new movieclip, copy and paste these frames in that movieclip. Similarly for other 3 buttons too.."
I don't understand what is meant by "these frames" and how would you paste them into a "movie clip." Please ... someone help me!
Thank You
.