Buttons for Movieclips!

2 posts

Flag Post

Ok I’m here to teach those who don’t know, a method used in dress-up games and such, a trick that when you to click a button, it will make a Movieclip change frame. It may sound simple; well that’s becasue it is.

First off:

Make a new Flash document. Any dimensions will do. Now create a new symbol (Insert>New Symbol…) and select Movieclip. Name is anything you want. On you first frame put a

stop();

command in the ActionScript (AS) box (F9). Now go to your stage. Draw, for example, a person. Hit F7 to insert a blank keyframe, and draw that same person in a different pose (or different colour, it’s up to you). Make as many keyframes as you like. Once you’ve finished go back to your main timeline and drag your MC onto the stage. Give it an Instance Name of ‘person’, without the quotations.

The Buttons:

Make 2 buttons, one Next and one Back. In the ‘Next’ button put this code in the AS box:

on (release) {
tellTarget ("person") {
nextFrame();
}
}

(Thats for older Flash versions like Flash 5, but if you want the new code it’s:)

on(press){
person.nextFrame();
}

That means when you click and release that button, it will go to the next frame inside the MC ‘person’. Now in your ‘Back’ button it’s pretty much the same code only with a prevFrame(); difference. Here’s the code:

on(press){
person.prevFrame();
}

Now hit Crtl>Enter to test your movie.

~Penboy

 
Flag Post

I laready know how to do this but thanks anyways…