Basic question about listeners inside functions/conditional listening

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!


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