0
votes

hope there are still a few people here which like me simply can not separate from Flash (and Actionscript 2). :)

I am trying to make a little adventure in Flash, but my hitTest doesn't seem to work properly. I have a Movieclip "Player" and various Movieclips as playfields, like "Plains". If the "Player" hits "Plains", my scene should "gotoAndStop" to the corresponding frame, also called "Plains". The "player" controls via a compass (click east and players x moves +20), the collision with the playfields is done by hitTest. See screenshots below.

My problem: Unfortunately the hitTest query works only with one of the game fields (the bottom one in the screenshot). Has anyone got an idea why that is? I am short of despair, already spent the whole weekend and simply can't find no solution.

Thanks in advance krake82

Screenshot

1
Insufficient information. There's no telling which one of the objects is the player, which one is the feld_plains, and what is the hierarchy of the objects. - Organis
Thanks for the input, Organis. The purple circle is the "Player" and the two green fields are both "feld_plains" also with the instance name "feld_plains". The lower right star is the compass, which controls the player movement. When the Player hits one of the "feld_plains" flash should jump to frame 10, named "plains". If Player does not hit "feld_plains" it should jump back to frame 1, named "start". Hope that helped to clarify. Kind regards. - krake82
Do I get it right that you have 2 different objects with the same name? - Organis
Yeah, is that a problem? I wanted to build a map with the objects and of course would have multiple copies of "feld_plains", jungle, water, etc. I thought working with a variable and an if-query that it should work, no? - krake82
Well, you have two friends, both named Fred. You call "Fred!" Which one of them respond? You can have multiple copies of one Library object, but you should have a way to directly address each single one of them. If you give them same instance names only one of them will be available for you to work with. - Organis

1 Answers

1
votes

It has been a while (AS2) still use AS3 - but you can't have 2 movieclips on the screen with the same Name and call to all of them - like if you had a zombie - you would have to use zombie[1], zombie[2] - you could do this from an array.

The other way (not necessarily best but effective) would be to create a movie clip with code "in it" thereby making it sort of "self-sufficient" the code in the clip could react without using outside code (in most cases).