Be a Supporter!

Replacing Movie Clips on the Stage

  • 278 Views
  • 6 Replies
New Topic Respond to this Topic
ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Replacing Movie Clips on the Stage 2007-05-24 23:54:04 Reply

I'm making this game for a final project in school. The game is a lot like this one. That's actually where I got the idea from. My problem is, I don't know how to change the MC's on the stage from the normal stance to the dancing. For example:

I have 3 buttons for the legs. When you click the first one I want the normal legs to start dancing. When you press the second button they start a different dance and the third button puts them back to normal. I've only been using Flash for like a year and AS for a few months. Here's the way I planned to do it.

When you start, and when all dances are stopped, the stage contains all the Normal, still Graphics, where nothing is moving. When you click the first leg button the legs graphic(or whatever is on the stage at the time) is replaced with the first legs MC. The second button will replace whatever is on the stage with the second movie clip and the third button will change it back to the normal, still graphic.

This same process will be used for the head, arms, face and music. I figured that would be the easiest way but I'm not sure exactly what kind of AS I'd use for it. I've been searching through AS: Main for a while and I can't seem to find what I'm looking for. If anyone has any idea how to do this, or if there's a better way, please let me know. Any help would be greatly appreciated.

Thanks


AS: Main

Don't read this sentence.

ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Replacing Movie Clips on the Stage 2007-05-25 01:03:36 Reply

I just read something in AS: Main about duplicating movie clips. Would attachMovie be an option here?

Another thing I was thinking about, would I have to write code for each possible situation? Like, if I want to replace leg1 MC with leg2 MC it would be one line of code. Replacing leg1 with leg3 is another, leg2 with leg1 another, etc. Or is it possible to say "When this button is clicked place the MC leg2 at the position 'legs'?" So rather than replacing what is already on the stage, you're getting rid of what was there and placing something else in the same spot.


AS: Main

Don't read this sentence.

3dwarrior
3dwarrior
  • Member since: Nov. 3, 2003
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Replacing Movie Clips on the Stage 2007-05-25 01:53:59 Reply

Your thinking in the wrong direction... what you would do for a game like that is just have one movie clip for example for the legs, and on different frames have different movie clips which would contain the animation.
ex. main legs mc -> standing, or walking, or whatever...

All you would have to do is go to the right frame... (make sure to have a stop(); code in each frame). I think you can get the rest...


AS2 Main | AS3 Main | Flash Wiki There is no excuse for not trying to learn. Linux.

BBS Signature
ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Replacing Movie Clips on the Stage 2007-05-25 01:56:09 Reply

OK, I actually think I figured this out after I learned about the tellTarget function.

So rather than make an MC for each dance I make one MC for each body part.
My leg MC contains all the different dances that the legs do as well as the normal legs.
In my leg MC (and all other parts) I have it set so that say, frame 1 is labeled one, and I have my normal legs. In frame two I label it two and have a short 10 frame animation loop. Frame 12 is labeled three and contains my next looped dance animation, etc. When I put the MC on the stage I label the instance "legs."

Now, in the code for the second leg button (to make him dance) I have the following:

on (release)
{
tellTarget("/legs")
{
gotoAndPlay("two");
} // End TellTarget
}

So now, when that button is clicked it goes to my dance animation inside that MC and will loop until another button is pressed. The other buttons are similar except that the "two" will change to the different numbers.

I will use basically the same code for the other body parts as well. So far it's working but if anyone has anything to say or ask, PLEASE do. I could use all the help I can get and I'll probably have more questions.


AS: Main

Don't read this sentence.

ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Replacing Movie Clips on the Stage 2007-05-25 01:59:49 Reply

At 5/25/07 01:53 AM, 3dwarrior wrote: Your thinking in the wrong direction... what you would do for a game like that is just have one movie clip for example for the legs, and on different frames have different movie clips which would contain the animation.
ex. main legs mc -> standing, or walking, or whatever...

All you would have to do is go to the right frame... (make sure to have a stop(); code in each frame). I think you can get the rest...

Yea, I think this is what I just realized lol. I didn't see your reply until after I just posted all that ^
Making all those MC's made it alot harder on myself. Now I just have one for each part that contains the different movements and I use tellTarget to gotoAndPlay those different movements. I'm still learning AS so I had never heard about tellTarget until now, it really came in handy :D.

Thanks for your reply


AS: Main

Don't read this sentence.

3dwarrior
3dwarrior
  • Member since: Nov. 3, 2003
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Replacing Movie Clips on the Stage 2007-05-25 02:04:43 Reply

At 5/25/07 01:59 AM, ChilliDog wrote: I'm still learning AS so I had never heard about tellTarget until now, it really came in handy :D.

I'm pretty sure tellTarget is an old function that isn't used anymore (depreciated, unless your in Flash 5 or whatever), so you should probably learn about Hierarchy.


AS2 Main | AS3 Main | Flash Wiki There is no excuse for not trying to learn. Linux.

BBS Signature
ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Replacing Movie Clips on the Stage 2007-05-25 02:19:01 Reply

At 5/25/07 02:04 AM, 3dwarrior wrote:
At 5/25/07 01:59 AM, ChilliDog wrote: I'm still learning AS so I had never heard about tellTarget until now, it really came in handy :D.
I'm pretty sure tellTarget is an old function that isn't used anymore (depreciated, unless your in Flash 5 or whatever), so you should probably learn about Hierarchy.

I'm actually using Flash 8 haha.
I've dealt with hierarchy before in 3d and animation and game creation n such, I didn't even think about how I could use it here. Dealing with parent and child and whatnot, right? I'll go read that. I saw it there earlier but didn't even consider it, duh. I should stop staying up so late, it's hard to think at 2am. Thanks for your help!


AS: Main

Don't read this sentence.