On the stage, you will see two small buttons: one pointing up ( volUp_btn) and one pointing down ( volDown_btn). We will just be adding the volume controls.
MAKE A REPLAY BUTTON IN FLASH ACTIONSCRIPT 3.0 CODE
}This code just loads the sound and creates the playing and stopping functionality. Stop_btn.addEventListener(MouseEvent.CLICK, stopSound) Play_btn.addEventListener(MouseEvent.CLICK, playSound) Var channel1:SoundChannel = new SoundChannel() Var songURL:URLRequest = new URLRequest("CheerfulSong.mp3") In the Actions Panel, you'll see that there's already some code: Open the exercise file and select the first frame of the Actions layer. You can use an if statement with an else clause in order to set constraints (which we will do later on). So if the volume property has a value that goes below 0, the sound volume comes back up. Negative values will actually increase the volume as well. But generally, you should only allow values between 0 - 1 (nothing greater nothing less) because values outside that range can end up distorting the sound. NOTE: The volume property can actually accept values that are greater than 1, as well as negative values. So this means that whatever sound is being played on that SoundChannel will have the volume adjustment applied to it. already a sound assigned to that channelĬhannel1.soundTransform = volumeAdjust This statement assigns the SoundTransform object named volumeAdjust, to the soundTransform property of the SoundChannel object named channel1. Assume that channel1 is a SoundChannel object and that there is Also notice that the soundTransform property starts with a lowercase s, while the SoundTransform class starts with an uppercase S.
A SoundTransform object is what holds the value for the volume level adjustment, where as the soundTransform property of the SoundChannel class is used in order to apply that volume level adjustment to the sound.
NOTE: Be aware of the distinction between a SoundTransform object (which would be an instance of the SoundTransform class) and the soundTransform property (which is a property of the SoundChannel class).