Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Stop and play nested MovieClip problem

Participant ,
Sep 13, 2015 Sep 13, 2015

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);

  }

}

TOPICS
ActionScript
542
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Sep 16, 2015 Sep 16, 2015

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)) {

 

...
Translate
LEGEND ,
Sep 13, 2015 Sep 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 16, 2015 Sep 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 16, 2015 Sep 16, 2015

Have you tried reversing the commands?

if (bomb1.hitTestObject(gLine1)) {

  bomb1.bomb2.gotoAndPlay(31); 

  bomb1.stop();

  }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 16, 2015 Sep 16, 2015
LATEST

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);

    }

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines