Make a button from a MovieClip – Tips & Tricks

movieclipbtnIn the first meeting of A-SFUG I showed a tip about creating the up, over and down states of a button using a movie clip. I thought that I should put it up here as a reference.

An easy way of creating a button from a movie clip is to give the names of the frames with the different states of the button "_up", "_over" and "_down".

Add a stop(); frame on frame 1 of the movie clip. Then out on the main timeline, open the actions panel and write:

myButton_btn.buttonMode = true;

Just change myButton_btn to the instance name of your movieclip.

Now test the movie and roll over the button and It will now go to the over state. Press down on it and it will go to the down state.

So you do not need to write the code for on roll over, on mouse down and on roll out. Flash will automatically detect what you are wanting to do and do it for you.

Now you may be asking "Why should I do it this way? Why can't I just make it as a regular button?" Well you can still do it that way if you like, however the benefit of doing it this way is that a movie clip is more light weight then a button. This means that flash can run a bit faster.

Cheers,
Ed

Tags: , ,

Leave a Reply