12 Replies Latest reply on Jun 30, 2010 8:36 AM by xcmuddman

    Making audio play and pause/stop when different buttons pressed

    xcmuddman Level 1

      Hi All,

       

      i am making a simple radio interface and i have 6 preset buttons which i want to have play the specific preset button's song which is in the library and stop/pause the current song when any preset button is pressed.

       

      i tried using the attachSound function, with associated identifiers but not sure if that is the right way to go. It plays the songs, but doesnt stop them...

       

      mc_FM1preset1.onRelease=function(){
          if(!this.toggle){
              this.gotoAndStop("release");
              radio_FM1.text = FM1preset1
              FM1value = 1
             
              PlayFM1_1 = new Sound(this);
              PlayFM1_1.attachSound(FM1preset1_song);
              PlayFM1_1.start(0, 1);
             
              PlayFM1_6.pause;
              PlayFM1_5.pause;
              PlayFM1_4.pause;
              PlayFM1_3.pause;
              PlayFM1_2.pause;
             
              }
          }

       

        
          }
      mc_FM1preset2.onRelease=function(){
          if(!this.toggle){
              this.gotoAndStop("release");
              radio_FM1.text = FM1preset2
              FM1value=2
             
              PlayFM1_2 = new Sound(this);
              PlayFM1_2.attachSound(FM1preset2_song);
              PlayFM1_2.start(0, 1);
             
              PlayFM1_6.pause;
              PlayFM1_5.pause;
              PlayFM1_4.pause;
              PlayFM1_3.pause;
              PlayFM1_1.unload;
             
              }   
          }

       

       

       

       

       

       

      then i tried just putting each song in its own movie clip and using this code, but it still didnt stop/pause the song.

       

      stop();

       

      mc_preset1.onRelease=function(){
              mc_song1.play();
              mc_song2.stop();
      }

       


      mc_preset2.onRelease=function(){
              mc_song2.play();
              mc_song1.stop(1);
      }

       

       

       

       

      Does anyone have any suggestions? Any help would be great! thanks!!!

       

      Basically i just need to know how to make the button or mc pressed to STOP / PAUSE the song thats playing

       

       

       

      THANKS!!!

       

      - PAt

        • 1. Re: Making audio play and pause/stop when different buttons pressed
          kglad Adobe Community Professional & MVP

          the sound class has no pause property.  it has a stop() method you should be using:

           


           

          mc_FM1preset1.onRelease=function(){
              if(!this.toggle){
                  this.gotoAndStop("release");
                  radio_FM1.text = FM1preset1
                  FM1value = 1
                 
                  PlayFM1_1 = new Sound(this);
                  PlayFM1_1.attachSound(FM1preset1_song);
                  PlayFM1_1.start(0, 1);
                 
                  PlayFM1_6.stop();
                  PlayFM1_5.stop();  //etc
                  PlayFM1_4.pause;
                  PlayFM1_3.pause;
                  PlayFM1_2.pause;
                 
                  }
              }

           

            
              }
          mc_FM1preset2.onRelease=function(){
              if(!this.toggle){
                  this.gotoAndStop("release");
                  radio_FM1.text = FM1preset2
                  FM1value=2
                 
                  PlayFM1_2 = new Sound(this);
                  PlayFM1_2.attachSound(FM1preset2_song);
                  PlayFM1_2.start(0, 1);
                 
                  PlayFM1_6.pause;
                  PlayFM1_5.pause;
                  PlayFM1_4.pause;
                  PlayFM1_3.pause;
                  PlayFM1_1.unload;
                 
                  }   
              }

          • 2. Re: Making audio play and pause/stop when different buttons pressed
            xcmuddman Level 1

            thanks KGLAD! i searched around yesterday and got it working (almost fully) with the following code. The only thing that is happening now is that when i go to a different scene / scenes, and then re-enter the scene thats playing the music and try to click on a different preset button that preset's sound plays, but the sound that's currently playing does not stop.

             

            I noticed you used the "unload" function... is this what i need to do to fix this problem? I have 6 different presets so im not quite sure how i would make the random pressed preset recognize the current song playing and unload that...

             

            a portion of my code follows:

             


            mc_FM1preset1.onPress=function(){
                if(!this.toggle){
                    this.gotoAndStop("press");
                    mc_FM1preset2.gotoAndStop("up");
                    mc_FM1preset3.gotoAndStop("up");
                    mc_FM1preset4.gotoAndStop("up");
                    mc_FM1preset5.gotoAndStop("up");
                    mc_FM1preset6.gotoAndStop("up");
                    }
                }
               
            mc_FM1preset1.onRelease=function(){
                if(!this.toggle){
                    this.gotoAndStop("release");
                    radio_FM1.text = FM1preset1
                    FM1value = 1
                   
                    preset1_song.start(preset1_song.position / 1000);
                    preset2_song.stop();
                    preset3_song.stop();
                    preset4_song.stop();
                    preset5_song.stop();
                    preset6_song.stop();
                    break;
                   
                    }
                }

             

            mc_FM1preset2.onPress=function(){
                if(!this.toggle){
                    this.gotoAndStop("press");
                    mc_FM1preset1.gotoAndStop("up");
                    mc_FM1preset3.gotoAndStop("up");
                    mc_FM1preset4.gotoAndStop("up");
                    mc_FM1preset5.gotoAndStop("up");
                    mc_FM1preset6.gotoAndStop("up");
                    }   
                }
            mc_FM1preset2.onRelease=function(){
                if(!this.toggle){
                    this.gotoAndStop("release");
                    radio_FM1.text = FM1preset2
                    FM1value=2
                   
                    preset2_song.start(preset2_song.position / 1000);
                    preset1_song.stop();
                    preset3_song.stop();
                    preset4_song.stop();
                    preset5_song.stop();
                    preset6_song.stop();
                    break;
                   
                    }   
                }

             

            mc_MUTE.onPress=function(){
                this.gotoAndStop("mute_press");
                preset1_song.setVolume(0);
                preset2_song.setVolume(0);
                preset3_song.setVolume(0);
                preset4_song.setVolume(0);
                preset5_song.setVolume(0);
                preset6_song.setVolume(0);
                }

             

            mc_MUTE.onRelease=function(){
                this.swapDepths(mc_UNMUTE);
                this.gotoAndStop("mute_up");
                }

             

            mc_UNMUTE.onPress=function(){
                this.gotoAndStop("sound_press");
                preset1_song.setVolume(100);
                preset2_song.setVolume(100);
                preset3_song.setVolume(100);
                preset4_song.setVolume(100);
                preset5_song.setVolume(100);
                preset6_song.setVolume(100);
                }
                   
            mc_UNMUTE.onRelease = function(){
                this.swapDepths(mc_MUTE);
                this.gotoAndStop("sound_up");
            }

             

             

             

            Thanks much!

             

            - PAt

            • 3. Re: Making audio play and pause/stop when different buttons pressed
              kglad Adobe Community Professional & MVP

              your sounds should be instantiated once.  you're probably re-instantiating them when you reenter that frame.

              1 person found this helpful
              • 4. Re: Making audio play and pause/stop when different buttons pressed
                xcmuddman Level 1

                hmmm, not sure how to do that... i tried taking all of this part of the code for each preset and moving it to the intro of my movie that  cannot be returned to, but when i did that only the opening sound  played... none of the presets worked...


                "

                presetX_song = new Sound(presetX_holder);
                presetX_song.attachSound("presetX_song");

                "


                 

                below is all of the code that is in the scene containing the FM presets... can you see what i am doing wrong?



                preset0_song = new Sound(preset0_holder);
                preset0_song.attachSound("preset0_song");

                 

                preset1_song = new Sound(preset1_holder);
                preset1_song.attachSound("preset1_song");

                 

                preset2_song = new Sound(preset2_holder);
                preset2_song.attachSound("preset2_song");

                 

                preset3_song = new Sound(preset3_holder);
                preset3_song.attachSound("preset3_song");

                 

                preset4_song = new Sound(preset4_holder);
                preset4_song.attachSound("preset4_song");

                 

                preset5_song = new Sound(preset5_holder);
                preset5_song.attachSound("preset5_song");

                 

                preset6_song = new Sound(preset6_holder);
                preset6_song.attachSound("preset6_song");

                 

                 

                 


                if (FM1value == 1){
                mc_FM1preset1.gotoAndStop("release");
                        radio_FM1.text = FM1preset1;

                 

                }
                else if (FM1value == 2){
                mc_FM1preset2.gotoAndStop("release");
                        radio_FM1.text = FM1preset2;

                 

                }
                else if (FM1value == 3){
                    mc_FM1preset3.gotoAndStop("release");
                            radio_FM1.text = FM1preset3;
                            preset3_song.start(preset3_song.position / 1000);

                 


                }
                else if (FM1value == 4){
                    mc_FM1preset4.gotoAndStop("release");
                            radio_FM1.text = FM1preset4;

                 

                }
                else if (FM1value == 5){
                    mc_FM1preset5.gotoAndStop("release");
                            radio_FM1.text = FM1preset5;

                 

                }
                else if (FM1value == 6){
                    mc_FM1preset6.gotoAndStop("release");
                            radio_FM1.text = FM1preset6;

                 

                }
                else radio_FM1.text = "91.3";

                 


                mc_FM1preset1.onPress=function(){
                    if(!this.toggle){
                        this.gotoAndStop("press");
                        mc_FM1preset2.gotoAndStop("up");
                        mc_FM1preset3.gotoAndStop("up");
                        mc_FM1preset4.gotoAndStop("up");
                        mc_FM1preset5.gotoAndStop("up");
                        mc_FM1preset6.gotoAndStop("up");
                        }
                    }
                   
                mc_FM1preset1.onRelease=function(){
                    if(!this.toggle){
                        this.gotoAndStop("release");
                        radio_FM1.text = FM1preset1
                        FM1value = 1
                       
                        preset1_song.start(preset1_song.position / 1000);
                        preset2_song.stop();
                        preset3_song.stop();
                        preset4_song.stop();
                        preset5_song.stop();
                        preset6_song.stop();
                        break;
                       
                        }
                    }

                 

                mc_FM1preset2.onPress=function(){
                    if(!this.toggle){
                        this.gotoAndStop("press");
                        mc_FM1preset1.gotoAndStop("up");
                        mc_FM1preset3.gotoAndStop("up");
                        mc_FM1preset4.gotoAndStop("up");
                        mc_FM1preset5.gotoAndStop("up");
                        mc_FM1preset6.gotoAndStop("up");
                        }   
                    }
                mc_FM1preset2.onRelease=function(){
                    if(!this.toggle){
                        this.gotoAndStop("release");
                        radio_FM1.text = FM1preset2
                        FM1value=2
                       
                        preset2_song.start(preset2_song.position / 1000);
                        preset1_song.stop();
                        preset3_song.stop();
                        preset4_song.stop();
                        preset5_song.stop();
                        preset6_song.stop();
                        break;
                       
                        }   
                    }
                   
                mc_FM1preset3.onPress=function(){
                    if(!this.toggle){
                        this.gotoAndStop("press");
                        mc_FM1preset1.gotoAndStop("up");
                        mc_FM1preset2.gotoAndStop("up");
                        mc_FM1preset4.gotoAndStop("up");
                        mc_FM1preset5.gotoAndStop("up");
                        mc_FM1preset6.gotoAndStop("up");
                        }   
                    }
                mc_FM1preset3.onRelease=function(){
                    if(!this.toggle){
                        this.gotoAndStop("release");
                        radio_FM1.text = FM1preset3
                        FM1value = 3
                       
                        preset3_song.start(preset3_song.position / 1000);
                        preset1_song.stop();
                        preset2_song.stop();
                        preset4_song.stop();
                        preset5_song.stop();
                        preset6_song.stop();
                        break;
                       
                        }   
                    }
                   
                mc_FM1preset4.onPress=function(){
                    if(!this.toggle){
                        this.gotoAndStop("press");
                        mc_FM1preset1.gotoAndStop("up");
                        mc_FM1preset2.gotoAndStop("up");
                        mc_FM1preset3.gotoAndStop("up");
                        mc_FM1preset5.gotoAndStop("up");
                        mc_FM1preset6.gotoAndStop("up");
                        }   
                    }
                mc_FM1preset4.onRelease=function(){
                    if(!this.toggle){
                        this.gotoAndStop("release");
                        radio_FM1.text = FM1preset4
                        FM1value = 4
                       
                        preset4_song.start(preset4_song.position / 1000);
                        preset1_song.stop();
                        preset2_song.stop();
                        preset3_song.stop();
                        preset5_song.stop();
                        preset6_song.stop();
                        break;

                 

                        }   
                    }
                   
                mc_FM1preset5.onPress=function(){
                    if(!this.toggle){
                        this.gotoAndStop("press");
                        mc_FM1preset1.gotoAndStop("up");
                        mc_FM1preset2.gotoAndStop("up");
                        mc_FM1preset3.gotoAndStop("up");
                        mc_FM1preset4.gotoAndStop("up");
                        mc_FM1preset6.gotoAndStop("up");
                        }   
                    }
                mc_FM1preset5.onRelease=function(){
                    if(!this.toggle){
                        this.gotoAndStop("release");
                        radio_FM1.text = FM1preset5
                        FM1value = 5
                       
                        preset5_song.start(preset5_song.position / 1000);
                        preset1_song.stop();
                        preset2_song.stop();
                        preset3_song.stop();
                        preset4_song.stop();
                        preset6_song.stop();
                        break;

                 

                        }   
                    }
                   
                mc_FM1preset6.onPress=function(){
                    if(!this.toggle){
                        this.gotoAndStop("press");
                        mc_FM1preset1.gotoAndStop("up");
                        mc_FM1preset2.gotoAndStop("up");
                        mc_FM1preset3.gotoAndStop("up");
                        mc_FM1preset4.gotoAndStop("up");
                        mc_FM1preset5.gotoAndStop("up");
                        }   
                    }
                mc_FM1preset6.onRelease=function(){
                    if(!this.toggle){
                        this.gotoAndStop("release");
                        radio_FM1.text = FM1preset6
                        FM1value = 6
                       
                        preset6_song.start(preset6_song.position / 1000);
                        preset1_song.stop();
                        preset2_song.stop();
                        preset3_song.stop();
                        preset4_song.stop();
                        preset5_song.stop();
                   
                        break;
                       
                        }   
                    }

                 

                mc_MUTE.onPress=function(){
                    this.gotoAndStop("mute_press");
                    preset1_song.setVolume(0);
                    preset2_song.setVolume(0);
                    preset3_song.setVolume(0);
                    preset4_song.setVolume(0);
                    preset5_song.setVolume(0);
                    preset6_song.setVolume(0);
                    }

                 

                mc_MUTE.onRelease=function(){
                    this.swapDepths(mc_UNMUTE);
                    this.gotoAndStop("mute_up");
                    }

                 

                mc_UNMUTE.onPress=function(){
                    this.gotoAndStop("sound_press");
                    preset1_song.setVolume(100);
                    preset2_song.setVolume(100);
                    preset3_song.setVolume(100);
                    preset4_song.setVolume(100);
                    preset5_song.setVolume(100);
                    preset6_song.setVolume(100);
                    }
                       
                mc_UNMUTE.onRelease = function(){
                    this.swapDepths(mc_MUTE);
                    this.gotoAndStop("sound_up");
                }

                 

                 

                 


                /*if (Audio == 1){
                    mc_MUTE.onPress=function(){
                        this.gotoAndStop("mute_press");
                        stopAllSounds();
                    }
                    mc_MUTE.onRelease = function(){
                        this.gotoAndStop("mute_up");
                    }
                }

                 

                else if (Audio == 2){
                    mc_MUTE.onPress=function(){
                        this.gotoAndStop("sound_press");
                        }   
                    mc_MUTE.onRelease=function(){
                        this.gotoAndStop("sound_up");
                    }   
                }
                */

                 

                   
                   
                   
                   
                btn_AM.onRelease = function()
                    {
                    gotoAndStop("RadioAM", 1);
                    }
                   

                 


                btn_CD.onRelease = function()
                    {
                    gotoAndStop("CD", 1);
                    }
                   
                btn_AUX.onRelease = function()
                    {
                    gotoAndStop("AUX", 1);
                    }
                   
                btn_SAT.onRelease = function()
                    {
                    gotoAndStop("SAT", 1);
                    }
                   
                btn_VIDEO.onRelease = function()
                    {
                    gotoAndStop("Video", 1);
                    }

                 

                 

                I thank you!

                 

                P

                • 5. Re: Making audio play and pause/stop when different buttons pressed
                  kglad Adobe Community Professional & MVP

                  use:

                   


                  var songsInstantiated:Boolean

                   

                  if(!songsInstantiated){

                  songsInstantiated=true;

                  preset0_song = new Sound(preset0_holder);
                  preset0_song.attachSound("preset0_song");

                   

                  preset1_song = new Sound(preset1_holder);
                  preset1_song.attachSound("preset1_song");

                   

                  preset2_song = new Sound(preset2_holder);
                  preset2_song.attachSound("preset2_song");

                   

                  preset3_song = new Sound(preset3_holder);
                  preset3_song.attachSound("preset3_song");

                   

                  preset4_song = new Sound(preset4_holder);
                  preset4_song.attachSound("preset4_song");

                   

                  preset5_song = new Sound(preset5_holder);
                  preset5_song.attachSound("preset5_song");

                   

                  preset6_song = new Sound(preset6_holder);
                  preset6_song.attachSound("preset6_song");

                  }

                   

                   

                   


                  if (FM1value == 1){
                  mc_FM1preset1.gotoAndStop("release");
                          radio_FM1.text = FM1preset1;

                   

                  }
                  else if (FM1value == 2){
                  mc_FM1preset2.gotoAndStop("release");
                          radio_FM1.text = FM1preset2;

                   

                  }
                  else if (FM1value == 3){
                      mc_FM1preset3.gotoAndStop("release");
                              radio_FM1.text = FM1preset3;
                              preset3_song.start(preset3_song.position / 1000);

                   


                  }
                  else if (FM1value == 4){
                      mc_FM1preset4.gotoAndStop("release");
                              radio_FM1.text = FM1preset4;

                   

                  }
                  else if (FM1value == 5){
                      mc_FM1preset5.gotoAndStop("release");
                              radio_FM1.text = FM1preset5;

                   

                  }
                  else if (FM1value == 6){
                      mc_FM1preset6.gotoAndStop("release");
                              radio_FM1.text = FM1preset6;

                   

                  }
                  else radio_FM1.text = "91.3";

                   


                  mc_FM1preset1.onPress=function(){
                      if(!this.toggle){
                          this.gotoAndStop("press");
                          mc_FM1preset2.gotoAndStop("up");
                          mc_FM1preset3.gotoAndStop("up");
                          mc_FM1preset4.gotoAndStop("up");
                          mc_FM1preset5.gotoAndStop("up");
                          mc_FM1preset6.gotoAndStop("up");
                          }
                      }
                     
                  mc_FM1preset1.onRelease=function(){
                      if(!this.toggle){
                          this.gotoAndStop("release");
                          radio_FM1.text = FM1preset1
                          FM1value = 1
                         
                          preset1_song.start(preset1_song.position / 1000);
                          preset2_song.stop();
                          preset3_song.stop();
                          preset4_song.stop();
                          preset5_song.stop();
                          preset6_song.stop();
                          break;
                         
                          }
                      }

                   

                  mc_FM1preset2.onPress=function(){
                      if(!this.toggle){
                          this.gotoAndStop("press");
                          mc_FM1preset1.gotoAndStop("up");
                          mc_FM1preset3.gotoAndStop("up");
                          mc_FM1preset4.gotoAndStop("up");
                          mc_FM1preset5.gotoAndStop("up");
                          mc_FM1preset6.gotoAndStop("up");
                          }   
                      }
                  mc_FM1preset2.onRelease=function(){
                      if(!this.toggle){
                          this.gotoAndStop("release");
                          radio_FM1.text = FM1preset2
                          FM1value=2
                         
                          preset2_song.start(preset2_song.position / 1000);
                          preset1_song.stop();
                          preset3_song.stop();
                          preset4_song.stop();
                          preset5_song.stop();
                          preset6_song.stop();
                          break;
                         
                          }   
                      }
                     
                  mc_FM1preset3.onPress=function(){
                      if(!this.toggle){
                          this.gotoAndStop("press");
                          mc_FM1preset1.gotoAndStop("up");
                          mc_FM1preset2.gotoAndStop("up");
                          mc_FM1preset4.gotoAndStop("up");
                          mc_FM1preset5.gotoAndStop("up");
                          mc_FM1preset6.gotoAndStop("up");
                          }   
                      }
                  mc_FM1preset3.onRelease=function(){
                      if(!this.toggle){
                          this.gotoAndStop("release");
                          radio_FM1.text = FM1preset3
                          FM1value = 3
                         
                          preset3_song.start(preset3_song.position / 1000);
                          preset1_song.stop();
                          preset2_song.stop();
                          preset4_song.stop();
                          preset5_song.stop();
                          preset6_song.stop();
                          break;
                         
                          }   
                      }
                     
                  mc_FM1preset4.onPress=function(){
                      if(!this.toggle){
                          this.gotoAndStop("press");
                          mc_FM1preset1.gotoAndStop("up");
                          mc_FM1preset2.gotoAndStop("up");
                          mc_FM1preset3.gotoAndStop("up");
                          mc_FM1preset5.gotoAndStop("up");
                          mc_FM1preset6.gotoAndStop("up");
                          }   
                      }
                  mc_FM1preset4.onRelease=function(){
                      if(!this.toggle){
                          this.gotoAndStop("release");
                          radio_FM1.text = FM1preset4
                          FM1value = 4
                         
                          preset4_song.start(preset4_song.position / 1000);
                          preset1_song.stop();
                          preset2_song.stop();
                          preset3_song.stop();
                          preset5_song.stop();
                          preset6_song.stop();
                          break;

                   

                          }   
                      }
                     
                  mc_FM1preset5.onPress=function(){
                      if(!this.toggle){
                          this.gotoAndStop("press");
                          mc_FM1preset1.gotoAndStop("up");
                          mc_FM1preset2.gotoAndStop("up");
                          mc_FM1preset3.gotoAndStop("up");
                          mc_FM1preset4.gotoAndStop("up");
                          mc_FM1preset6.gotoAndStop("up");
                          }   
                      }
                  mc_FM1preset5.onRelease=function(){
                      if(!this.toggle){
                          this.gotoAndStop("release");
                          radio_FM1.text = FM1preset5
                          FM1value = 5
                         
                          preset5_song.start(preset5_song.position / 1000);
                          preset1_song.stop();
                          preset2_song.stop();
                          preset3_song.stop();
                          preset4_song.stop();
                          preset6_song.stop();
                          break;

                   

                          }   
                      }
                     
                  mc_FM1preset6.onPress=function(){
                      if(!this.toggle){
                          this.gotoAndStop("press");
                          mc_FM1preset1.gotoAndStop("up");
                          mc_FM1preset2.gotoAndStop("up");
                          mc_FM1preset3.gotoAndStop("up");
                          mc_FM1preset4.gotoAndStop("up");
                          mc_FM1preset5.gotoAndStop("up");
                          }   
                      }
                  mc_FM1preset6.onRelease=function(){
                      if(!this.toggle){
                          this.gotoAndStop("release");
                          radio_FM1.text = FM1preset6
                          FM1value = 6
                         
                          preset6_song.start(preset6_song.position / 1000);
                          preset1_song.stop();
                          preset2_song.stop();
                          preset3_song.stop();
                          preset4_song.stop();
                          preset5_song.stop();
                     
                          break;
                         
                          }   
                      }

                   

                  mc_MUTE.onPress=function(){
                      this.gotoAndStop("mute_press");
                      preset1_song.setVolume(0);
                      preset2_song.setVolume(0);
                      preset3_song.setVolume(0);
                      preset4_song.setVolume(0);
                      preset5_song.setVolume(0);
                      preset6_song.setVolume(0);
                      }

                   

                  mc_MUTE.onRelease=function(){
                      this.swapDepths(mc_UNMUTE);
                      this.gotoAndStop("mute_up");
                      }

                   

                  mc_UNMUTE.onPress=function(){
                      this.gotoAndStop("sound_press");
                      preset1_song.setVolume(100);
                      preset2_song.setVolume(100);
                      preset3_song.setVolume(100);
                      preset4_song.setVolume(100);
                      preset5_song.setVolume(100);
                      preset6_song.setVolume(100);
                      }
                         
                  mc_UNMUTE.onRelease = function(){
                      this.swapDepths(mc_MUTE);
                      this.gotoAndStop("sound_up");
                  }

                   

                   

                   


                  /*if (Audio == 1){
                      mc_MUTE.onPress=function(){
                          this.gotoAndStop("mute_press");
                          stopAllSounds();
                      }
                      mc_MUTE.onRelease = function(){
                          this.gotoAndStop("mute_up");
                      }
                  }

                   

                  else if (Audio == 2){
                      mc_MUTE.onPress=function(){
                          this.gotoAndStop("sound_press");
                          }   
                      mc_MUTE.onRelease=function(){
                          this.gotoAndStop("sound_up");
                      }   
                  }
                  */

                   

                     
                     
                     
                     
                  btn_AM.onRelease = function()
                      {
                      gotoAndStop("RadioAM", 1);
                      }
                     

                   


                  btn_CD.onRelease = function()
                      {
                      gotoAndStop("CD", 1);
                      }
                     
                  btn_AUX.onRelease = function()
                      {
                      gotoAndStop("AUX", 1);
                      }
                     
                  btn_SAT.onRelease = function()
                      {
                      gotoAndStop("SAT", 1);
                      }
                     
                  btn_VIDEO.onRelease = function()
                      {
                      gotoAndStop("Video", 1);
                      }

                   

                   

                  I thank you!

                   

                  P

                  1 person found this helpful
                  • 6. Re: Making audio play and pause/stop when different buttons pressed
                    xcmuddman Level 1

                    Thank you KGLAD.

                     

                    i must have some of the code in the wrong spots though, because i am still having trouble...

                     

                    Currently the presets AND mute/unmute buttons work fine while in the FM scene, but as soon as i go to another scene the sound comes back from whatever song the preset is set to and i cannot mute it... is there a certain place i need to place the initial "attachSound" code? Also, these sounds are each being attached to their own movieClip... do i need to put the same instances of these same movieClips in all scenes throughout the movie?

                     

                    - Pat

                    • 7. Re: Making audio play and pause/stop when different buttons pressed
                      kglad Adobe Community Professional & MVP

                      that code was to allow your sounds to work when you return to your player.  does that work?

                       

                      there's no code, that i see, that stops your sound when you go elsewhere in your timeline.

                      • 8. Re: Making audio play and pause/stop when different buttons pressed
                        xcmuddman Level 1

                        Hi KGLAD,

                         

                        that code most likely works fine that you gave me, but i cant tell. My movie still does the same as it was doing before... It will play each sound on each preset in the RadioFM scene and the mute / unmute button works fine in this scene as well...   But as soon as i leave the RadioFM scene something causes a malfunction...

                         

                        When i gotoAndStop in another scene and the sound is playing it keeps playing fine, but will not mute.

                        When i gotoAndStop in another scene and the sound is muted it will become unmuted.

                         

                        When i return to the RadioFM scene the mute/unmute will not work.

                        When i click on any of the presets after returning to the RadioFM scene the new preset plays and the current song keeps playing.

                         

                        I made sure that i have both instances of the mute/unmute buttons in the other scenes and the code is there for them as well...

                         

                        i am stuck on this one...

                         

                        Any thoughts?

                         

                        - Pat

                        • 9. Re: Making audio play and pause/stop when different buttons pressed
                          kglad Adobe Community Professional & MVP

                          do all those movieclips preset0_holder and preset0_song etc exist when you navigate away from your player?

                          • 10. Re: Making audio play and pause/stop when different buttons pressed
                            xcmuddman Level 1

                            Yes... they are...

                             

                            should try a different way than the attachSound function?

                             

                            Is it because i am listing "new Sound" multiple times in the code?

                             

                             

                            I dont get why the sound starts up again when i go to another scene...

                             

                            i h

                            • 11. Re: Making audio play and pause/stop when different buttons pressed
                              kglad Adobe Community Professional & MVP

                              let's take the first problem.  a sound is playing, you navigate away and your mute doesn't work.

                               

                              if your mute button is using stopAllSounds(), that must mean your mute button doesn't exist when you navigate away.  to fix that, remove all keyframes, after the one where everything works, that contain your mute button.  retest.

                              • 12. Re: Making audio play and pause/stop when different buttons pressed
                                xcmuddman Level 1

                                Hi KGLAD,

                                 

                                sorry to have not gotten back to you on this in a while... I have been meaning to revisit this issue with the audio in my project but have been focusing on other aspects of it... i will try some of your suggestions and get back to you soon on this.

                                 

                                thanks.

                                 

                                - Pat