Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to stop timers when leaving a "screen"
    text
    copied!<p>I have some timers running on a page that I am having trouble figuring out how to stop when I navigate away from that page, while the page is running. </p> <p>The call is coming from a button on another movie clip, which is invoking a function on Main.as. The </p> <p>function in Main.as does this:</p> <pre><code>public function goToIntro(){ removeChild(currentScreen); intro = new Intro(); addChildAt(intro,0); currentScreen = intro; } </code></pre> <p>I get this error message if I click the Intro button while any scene with timers is playing. The message </p> <p>doesn't come up right away, it appears just as the Intro "scene" is ending and calling the next scene.</p> <pre><code>TypeError: Error #1009: Cannot access a property or method of a null object reference. at MethodInfo-202() at flash.utils::Timer/_timerDispatch() at flash.utils::Timer/tick() </code></pre> <p>I have this code on the Intro page, that is supposed to handle cleaning it up when it is removed.</p> <pre><code>public function Intro() { addEventListener(Event.REMOVED_FROM_STAGE, removedHandler); private function removedHandler(event:Event):void { } </code></pre> <p>I cannot figure out how to kill the timers from the removedHander function. I tried removing the event listeners but that causes other error messages. I tried doing a test if the listener is not null, then stopping it. That apparently never runs (I used trace statements to test it). I tried testing if the timer was .running and then stopping it, but that didnt work either.</p> <p>Help! </p> <p>Also, I am a complete newbie to actionscript and programming so it's ok to talk to me like I was a 5 year old. Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload