Be a Supporter!

AS: Buttons for Movieclips

  • 529 Views
  • 2 Replies
New Topic Respond to this Topic
Penboy
Penboy
  • Member since: Jun. 17, 2006
  • Offline.
Forum Stats
Member
Level 17
Artist
AS: Buttons for Movieclips Mar. 20th, 2007 @ 06:30 AM Reply

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!
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to AS: Buttons for Movieclips Mar. 20th, 2007 @ 06:37 AM Reply

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

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


- - Flash - Music - Images - -

BBS Signature
Penboy
Penboy
  • Member since: Jun. 17, 2006
  • Offline.
Forum Stats
Member
Level 17
Artist
Response to AS: Buttons for Movieclips Mar. 20th, 2007 @ 06:50 AM Reply

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