mute

Problem disabling audio after dragging and dropping as3


I made three pictures pulled to stick with three others, and it was done successfully. I wanted to add a reinforcement sound if the attachment was pulled and attached correctly, and another voice indicates dissatisfaction when the operation is not successful, Problem: Booster still works on all images after a one-time success, and failure sound does not work. That is, I was not able to correctly formulate symbols that control sounds from inside the library to work. Please help solve the problem

In the code: Names of images being pulled (r1, r2, r3), names of still images (m1, m2, m3), the sound of success mus1 and the sound of failure mus2

////////////////
 stop();
 r1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
 function fl_ClickToDrag(event:MouseEvent):void
 {
    r1.startDrag();
 }
 stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
 function fl_ReleaseToDrop(event:MouseEvent):void
 {
     r1.stopDrag();
    if(r1.hitTestObject(m1))
    {
        r1.x=m1.x
        r1.y=m1.y
    }
    else
    {
        r1.x=30.05
        r1.y=155.95
    }
 }
 r2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
 function fl_ClickToDrag_2(event:MouseEvent):void
 {
    r2.startDrag();
 }
 stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
 function fl_ReleaseToDrop_2(event:MouseEvent):void
 {
    r2.stopDrag();
    if(r2.hitTestObject(m2))
    {
        r2.x=m2.x
        r2.y=m2.y
        ///////////////Sound code for reinforcement
    var musAPlay:Ahsant = new Ahsant();
      var musA1Channel:SoundChannel = new SoundChannel();
     SoundMixer.stopAll();
    musA1Channel.stop();
     musA1Channel = musAPlay.play();
        
    }
    else
    {
        r2.x=30.05
        r2.y=249.4
        //////////////Sound code not being successful
        var musBPlay:noah = new noah();
    var musB1Channel:SoundChannel = new SoundChannel();
     SoundMixer.stopAll();
    musB1Channel.stop();
     musB1Channel = musBPlay.play();
        
    }
 }
 r3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_3);
 function fl_ClickToDrag_3(event:MouseEvent):void
 {
    r3.startDrag();
 }
 stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_3);
 function fl_ReleaseToDrop_3(event:MouseEvent):void
 {
    r3.stopDrag();
    if(r3.hitTestObject(m3))
    {
        r3.x=m3.x
        r3.y=m3.y
    }
    else
    {
        r3.x=30.05
        r3.y=347.4
    }
    
        if(r1.hitTestObject(m1)&& r2.hitTestObject(m2) && r3.hitTestObject(m3))
            gotoAndPlay (5)
    
 }
 //////////////////////////

Solution

  • I was able to solve the problem by replacing the stage with the name of the button, and after the code for the sound indicating for success, I put the following: button.removeEventListener(MouseEvent.MOUSE_DOWN, fl_ReleaseToDrop); button.removeEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);

    Where button is replaced with the custom name according to work