1 Reply Latest reply on May 30, 2007 12:34 PM by kglad

    Newbie with Sound Control with AS headaches

    mangamerica
      Hello,
      This is probably really easy to do, but I'm still new at scripting, so please be gentle ...
      Here's what I'm trying to do:

      When the main swf loads, welcome.mp3 plays once automatically.

      On the timeline, I have a movie clip with an instance name of BGM_controls. Inside it are two buttons, stop_btn, and play_btn. The movie clip contains some simple tweening to allow the buttons to fade in or out. I use frame labels to control the animation.

      When the movie begins and the music starts playing, stop_btn fades into view. On click, the music stops; stop_btn fades out from view; and play_btn appears. Then, when a user clicks play_btn, the music begins again; play_btn disappears and stop_btn re-appears.

      In case the user allows the music to play without interruption, stop_btn turns into play_btn when the song ends.

      Below is the script I put on the first frame of the timeline. The music plays, and the onSoundComplete function operates as planned, but the buttons themselves don't do anything. Can someone tell me what I'm doing wrong? Thanks a bunch!
      -------------------
      //Start playing welcome.mp3
      var my_sound:Sound = new Sound();
      my_sound.attachSound("welcome.mp3");
      //When song stops playing by itself, switches stop button to play button
      my_sound.onSoundComplete = function() {
      tellTarget ("_root.BGM_controls") {
      gotoAndPlay("stout");
      }
      };
      my_sound.start();
      //Behavior for stop button
      _root.BGM_controls.stop_btn.onRelease = function() {
      my_sound.stop();
      tellTarget ("_root.BGM_controls") {
      gotoAndPlay("stout");
      }
      };
      //Behavior for play button
      _root.BGM_controls.play_btn.onRelease = function() {
      my_sound.start();
      tellTarget ("_root.BGM_controls") {
      gotoAndPlay("stin");
      }
      };
      -------------------