Question

I have a hitTest setup to see if mc1 hits mc2. While mc1 is touching mc2, I need mc1 to play in a loop. mc1 oops after touching mc2 but not while it is touching mc2. While it is touching mc2 it goes to frame 2 and stops. Why is this happening?

Was it helpful?

Solution

The problem i am smelling in your code is that you must be using onEnterFrame method to check whether mc1 is touching mc2. And when hitTest returning true, you must be using:

mc1.gotoAndPlay(2);

The problem here is that by the time both MCs are hitting each other onEnterFrame method is forcing mc1 to go and play from frame no 2 24 times(depending upon the frame rate you are using) per second. And just because the transition is too fast, it seems to get stuck on frame no 2.

My suggestion would be to have a variable that registers the hitting of those MCs. And then request the mc1 to go and play. Here is a sample code you can refer to.

mc1.stop();
mc1.onPress = function() {
    startDrag(mc1);
};
mc1.onRelease = function() {
    stopDrag();
};
var touched = 0;
onEnterFrame = function () {
if (mc1.hitTest(mc2)) {
    trace("you hit the circle");
    mc1.play();
} else {
    touched = 0;
}
if (touched == 1) {
    mc1.play();
}else {
    mc1.stop();
}
};

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top