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

Timer, starts and end, and in between questions

Participant ,
May 18, 2015 May 18, 2015

Copy link to clipboard

Copied

1). This timer was designed to wait for the cation on stage to be finished and then to go to the next frame. The problem is that in the 'function finishMove' each condition runs only after the previous condition completed the full timer's cycle. so the first removeChild(gdropBall2); happens immediately, but  removeChild(Wall2Missing); get deleted 2 seconds later and the last removeChild(gdropBall1); get deleted 2 seconds after that. I want it all happened at the same time. How do I do that?

2). the function stopTimer was supposed to stop the timer but I'm not sure that it does, I had to put the conditions in 'function finishMove' because it errors on Child not found after it's been removed in the first timer's cycle.

'var timer2: Timer = new Timer(2000);

timer2.addEventListener(TimerEvent.TIMER, finishMove);

function checkScoreScene10(): void {

  if (scoreScene10 >= 300) {

  timer2.start();

  }

}

function finishMove(e: TimerEvent): void {

  if (stage.contains(gdropBall2)) {

  removeChild(gdropBall2);

  } else if (stage.contains(Wall2Missing)) {

  removeChild(Wall2Missing);

  } else if (stage.contains(gdropBall1)) {

  removeChild(gdropBall1);

  gotoAndStop(2);

  }

  function stopTimer(event: TimerEvent): void {

  timer2.removeEventListener(TimerEvent.TIMER, stopTimer);

  timer2 = null;

  }

}'

TOPICS
ActionScript

Views

279

Translate

Translate

Report

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
Explorer ,
May 18, 2015 May 18, 2015

Copy link to clipboard

Copied

LATEST

Try using 3 separate if conditional statements instead of 1 if and 2 else-if conditional statements. 

It looks like you inadvertently defined your stopTimer function inside your finishMove function.

You'll probably want to use the stop method of the Timer class in addition to removing your listener.

Timer - Adobe ActionScript® 3 (AS3 ) API Reference@

Votes

Translate

Translate

Report

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