Be a Supporter!

Actions for Duplicated MCs

  • 389 Views
  • 2 Replies
New Topic Respond to this Topic
ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Actions for Duplicated MCs 2007-06-03 22:27:53 Reply

Ok so, I have a button that when clicked opens up the floor and the object that was on the floor falls. It works right now because I only have on object on the floor but I want to add more. Eventually I want the player to be able to add more objects just by clicking a button and then when the floor is opened, all objects there will fall through.

So I took that one instance of the object that was on the stage and copy pasted it a couple of times. Now when i click the fall button all of the objects fall but only one of them plays the falling animation I added. Is there a way I can make it so no matter how many instances of the object there are on the stage, they will all fall and play the falling animation when the button is clicked?

Here is the code that is on the floorMC which contains the button:
on(release) {
this.gotoAndPlay(3);
_root.teddy.gotoAndPlay("fall");
}

Any help is greatly appreciated, thank you!


AS: Main

Don't read this sentence.

Kart-Man
Kart-Man
  • Member since: Jan. 7, 2007
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to Actions for Duplicated MCs 2007-06-03 22:34:51 Reply

You can't have multiple movie clips with the same instance name. Try something like:

on(release) {
this.gotoAndPlay(3);
for (i = 0; i < insertnumberhere; i++ ) {
_root["teddy"+i].gotoAndPlay("fall");
}
}

Untested, but nevertheless, you can try solving this by adding a for loop, then changing the instance name 'teddy' for all of the movie clips by renaming them 'teddy1', 'teddy2', etc...


postcount +=1;
Newgrounds Photoshop Headquarters || Don't use MS Paint! Use Aviary!
SING US A SING YOU'RE THE PIANO MAN

BBS Signature
ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Actions for Duplicated MCs 2007-06-03 22:53:24 Reply

Ok, I think I get what you're saying. Let me try this out.

Thanks!


AS: Main

Don't read this sentence.