Skip to main content
deborahb44958436
Inspiring
September 13, 2015
Answered

Stop and play nested MovieClip problem

  • September 13, 2015
  • 1 reply
  • 585 views

I'm trying to make a falling bomb and explosion effect. I created bomb1 with a nested motion tween and then I created bomb2 with the explosion effect nested another level deep inside bomb1. My hope was that when the bomb hit the target the motion downward will stop and at the same time there will be an explosion.  The problem is that I can't make both action happened at the same time, it either stops the motion completely or having the explosion while the bomb continue going downward. I can't make both action happened at the same time.  bomb1.stop(); should stop the motion down and bomb1.bomb2.gotoAndPlay(31); should make the explosion effect. Any Idea?


import flash.events.Event;

var bombPlaying: Boolean = true;

this.addEventListener(Event.ENTER_FRAME, handleCollision);

function handleCollision(evt: Event): void {

  if (bomb1.hitTestObject(gLine1)) {

  bomb1.stop();

  bomb1.bomb2.gotoAndPlay(31);

  }

}

This topic has been closed for replies.
Correct answer deborahb44958436

Have you tried reversing the commands?

if (bomb1.hitTestObject(gLine1)) {

  bomb1.bomb2.gotoAndPlay(31); 

  bomb1.stop();

  }


I got the problem solved. The eventListener had to be removed before   `bomb1.stop();bomb1.bomb2.gotoAndPlay(31);`

      import flash.events.Event;

       

        bomb1.gotoAndStop(1);

   

    myButton.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

   

    function fl_MouseClickHandler(event: MouseEvent): void {

    bomb1.gotoAndPlay(1);

    this.addEventListener(Event.ENTER_FRAME, handleCollision);

    }

    function handleCollision(evt: Event): void {

    if (bomb1.hitTestObject(gLine1)) {

    this.removeEventListener(Event.ENTER_FRAME, handleCollision);

    bomb1.stop();

    bomb1.bomb2.gotoAndPlay(31);

    }

    }

1 reply

robdillon
Participating Frequently
September 13, 2015

Do either of your bomb commands work? Does the bomb1 animation stop? Does the bomb1.bomb2 animation play?

Why does the bomb2 explosion animation start at frame 31?

deborahb44958436
Inspiring
September 16, 2015

each command works if the other command is removed. bomb1.stop works when bomb1.bomb2.gotoAndPlay(31); is not there and visa versa. bomb2 explosion effect starts at frame 31. before frame 31 I have the bomb flames effect.

robdillon
Participating Frequently
September 16, 2015

Have you tried reversing the commands?

if (bomb1.hitTestObject(gLine1)) {

  bomb1.bomb2.gotoAndPlay(31); 

  bomb1.stop();

  }