1 Reply Latest reply on Jul 9, 2009 4:44 AM by Ned Murphy

    Replacing movieclip with another movieclip when it's clicked on?

    keithwoods Level 1

      I've got music player and one of the controls is a movieclip which acts as a PLAY and PAUSE button. What I would like is to swap the image of this movieclip everytime it's clicked. How would I go about doing this?

      Here's my code...

      ActionScript Code:
      playPause_btn.addEventListener(MouseEvent.CLICK, onPlayPause);
      function onPlayPause(event:MouseEvent):void{
          if (song_paused == false)
          {
              song_position = my_channel.position;
              my_channel.stop();
              song_paused=true;
              // SWAP playPause_btn HERE
          }
          else if (song_paused)
          {
              my_channel = my_sound.play(song_position);
              song_paused=false;
              // SWAP playPause_btn HERE
          }
      }
        • 1. Re: Replacing movieclip with another movieclip when it's clicked on?
          Ned Murphy Adobe Community Professional & MVP
          Normally two buttons would be used and their visibility would be controlled based on play status.  In your case, since you are using the one button for both pause and play, you'll be best to have different frames that you move to in the movieclip_button for each condition.
          Also, you are unnecessarily testing both conditions since there are only two possible statuses for a Boolean variable...
              if (!song_paused)
              {
                  song_position = my_channel.position;
                  my_channel.stop();
                          // SWAP playPause_btn HERE
              }
              else
              {
                  my_channel = my_sound.play(song_position);
                  // SWAP playPause_btn HERE
              }
               song_paused=!song_paused;