Using same actionscript twice in one scene on different movie clips?

I am using the same actionscript twice on one scene, however for two different movie clips and only one works.

The one that works seems to be the one that is on a layer above the non working one, and the non working one is on a layer below.

Why is this. How can i resolve it?