# How to stop timers in nested code

**URL:** <https://forum.kirupa.com/t/how-to-stop-timers-in-nested-code/316897>\
**Category:** flash\
**Created:** [December 5, 2010, 6:07pm UTC](https://forum.kirupa.com/t/how-to-stop-timers-in-nested-code/316897 "2010-12-05T18:07:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaxz](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jaxz](https://forum.kirupa.com/u/jaxz)\
**Post date:** [December 5, 2010, 6:07pm UTC](https://forum.kirupa.com/t/how-to-stop-timers-in-nested-code/316897/1 "2010-12-05T18:07:54Z")

</div>

Hi all I have a media player with nested code that calls the start of new playback upon completion of a previous file  
**Code example**

```auto
function LoadNext_T(e:Event = null):void // set next theme
{
    if (A_play) {
     nextA = new Sound();
     nextA.addEventListener(Event.COMPLETE, PlayNextTheme,false, 0, true);
     nextA.load(gettheme);      
    }
    else {
      nextB = new Sound();
      nextB.addEventListener(Event.COMPLETE, PlayNextTheme,false, 0, true);
      nextB.load(gettheme);      
    }   
}

function PlayNextTheme(e:Event):void    
{
        if (A_play) {
            ThemeLong = nextA.length; 
            SC_A.soundTransform = volumeform_AB;                                                            
        }
        else {
            ThemeLong = nextB.length; 
            SC_B.soundTransform = volumeform_AB;            
        }
    var timer_AB: Timer = new Timer(ThemeLong - dt,1);  
    if (special conditions met) {
timer_AB.addEventListener(TimerEvent.TIMER, LoadNext_T,false, 0, true); 
        timer_AB.start();    
}

```

I wish to stop all timers when I hit my STOP button, but when writing a function like below, I just get an error saying “1120: Access of undefined property timer\_AB.” or such.

```auto

function STOP_ALL_TIMERS():void
{
// to stop all timers below call this from StopSong och pausesong
 if( timer_AB!= null) {timer_AB.stop();}
}

```

what am I to do here??  
pls help!

/Jaxz
