00:00
00:00
Newgrounds Background Image Theme

Chan99 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS: Buttons for Movieclips

1,207 Views | 2 Replies
New Topic Respond to this Topic

AS: Buttons for Movieclips 2007-03-20 06:30:10


AS: Main

=================

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();
}
}

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 (release) {
tellTarget ("person") {
prevFrame();
}
}

Now hit Crtl>Enter to test your movie.

Here's an example!

Yours not working? Download the .fla file!

=========================

This sort of thing is great for things such as:
+ Dress-up games
+ Tutorials

I hoped this helped :D

Tell me what you think!

Response to AS: Buttons for Movieclips 2007-03-20 06:37:19


You do realise that tellTarget is deprecated since Flash Player 5, right?

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


- - Flash - Music - Images - -

BBS Signature

Response to AS: Buttons for Movieclips 2007-03-20 06:50:39


At 3/20/07 06:37 AM, Denvish wrote: You do realise that tellTarget is deprecated since Flash Player 5, right?

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

No I wasn't aware, but both methods work so I guess there's no problem :D