# Basic question about listeners inside functions/conditional listening

**URL:** <https://forum.kirupa.com/t/basic-question-about-listeners-inside-functions-conditional-listening/305547>\
**Category:** Uncategorized\
**Created:** [February 27, 2010, 12:54am UTC](https://forum.kirupa.com/t/basic-question-about-listeners-inside-functions-conditional-listening/305547 "2010-02-27T00:54:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cut\_copy\_paste](https://avatars.discourse-cdn.com/v4/letter/c/eada6e/32.png) [@cut\_copy\_paste](https://forum.kirupa.com/u/cut_copy_paste)\
**Post date:** [February 27, 2010, 12:54am UTC](https://forum.kirupa.com/t/basic-question-about-listeners-inside-functions-conditional-listening/305547/1 "2010-02-27T00:54:01Z")

</div>

I’m a bit new to actiosncript/programming in general and I’m having a headstraing about how to accomplish something…

I have a net.status listener activating a function that loops a netstream player video, but i want a button to toggle it on and off. i have the button set up with an if/else toggle, and the looping going, but i can’t figure out how to turn the looping on and off from the button function…

i want to connect the vid4loop function to the loopswitch function… but am having a hard time figuring it out… and probably it’s something pretty basic that i just haven’t learned yet, just looking for some pointers!

```auto

loopbtnvid4.addEventListener(MouseEvent.CLICK,vid4loopswitch);
nsvid4.addEventListener(NetStatusEvent.NET_STATUS, nsvid4_loop);

var vid4LoopFlag:int = 0;

function nsvid4_loop(event:NetStatusEvent):void {
   if(event.info.code == "NetStream.Play.Stop"){
        nsvid4.seek(0);
   }
}

function vid4loopswitch (evt:MouseEvent):void{
    if(vid4LoopFlag == 0){
            vid4LoopFlag = 1;
            //turn off opacity//
            loopbtnvid4.alpha = 1;
        } else if(vid4LoopFlag ==1) {
            vid4LoopFlag = 0;
            loopbtnvid4.alpha = 0.5;
                  }
    }

```
