To change the volume, we can pass a object to the soundTransform property: player.soundTransform = new SoundTransform( 0.5 ) Īs mentioned above, SoundPlayer is a subclass of LayoutGroup. The seek() function may be called to change the current time: ek( 5.0 ) To stop playback and return the sound to the beginning, we may call stop(): player.stop() The togglePlayPause() method may be called to toggle between the play and pause states: player.togglePlayPause() To pause, we can call pause() to pause playback at the current position: player.pause() If autoPlay is set to false, we can call play() to begin playback manually: ay() We can use the autoPlay property to change this behavior: toPlay = false Controlling playback programmaticallyīy default, the SoundPlayer will automatically start playing its soundSource. Now, because we've set the percentWidth property, when the width of the SoundPlayer changes, the width of the SeekSlider will change too. If we want our SeekSlider to stretch to fill as much space as possible within the SoundPlayer, we can pass in HorizontalLayoutData: var sliderLayoutData:HorizontalLayoutData = new HorizontalLayoutData()
FLASH ACTIONSCRIPT 3.0 PASS SOUND TO FUNCITON HOW TO
See How to use HorizontalLayout with Feathers containers for complete details. Here, we've set the gap property, but HorizontalLayout provides many more useful features, including padding and alignment. Let's pass a HorizontalLayout to the layout property of the SoundPlayer: var layout:HorizontalLayout = new HorizontalLayout() Like a LayoutGroup, a SoundPlayer supports using layouts to automatically position and size its children. In the next section, we'll position these two children using a layout.
![flash actionscript 3.0 pass sound to funciton flash actionscript 3.0 pass sound to funciton](https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/images/ca_calloutButton_ca.png)
The complete list of media player controls includes several more pre-built components that you can add to a SoundPlayer. You simply need to add them as children of the SoundPlayer, and everything will be set up automatically.
![flash actionscript 3.0 pass sound to funciton flash actionscript 3.0 pass sound to funciton](https://i.ytimg.com/vi/QZAnlMaSxCQ/maxresdefault.jpg)
There's no need to add event listeners for these controls. Var slider:SeekSlider = new SeekSlider() It's as simple as adding them as children of the SoundPlayer: var button:PlayPauseToggleButton = new PlayPauseToggleButton() Let's give the SoundPlayer a PlayPauseToggleButton and a SeekSlider. Next, we'll add some components as children to control playback. To play a sound file, pass the URL (or a object) to the soundSource property: player.soundSource = "" A SoundPlayer component with controls skinned with MetalWorksMobileThemeįirst, let's create a SoundPlayer component and add it to the display list: var player:SoundPlayer = new SoundPlayer() SoundPlayer is a subclass of LayoutGroup, so its children may be positioned and sized using layouts. Media player controls may be added as children to display information such as the current time or to control playback by seeking or pausing the audio.
![flash actionscript 3.0 pass sound to funciton flash actionscript 3.0 pass sound to funciton](https://i2.wp.com/i182.photobucket.com/albums/x186/song_teo/1-12.png)
Sound files may be loaded from a URL or any Sound object may be passed in. NstepListener.The SoundPlayer class provides audio playback capabilities using a object. SilenceLevel_nstep.value = active_mic.silenceLevel SilenceLevel_pb.label = "Activity level: %3" Var active_mic:Microphone = Microphone.get() This.createEmptyMovieClip("sound_mc", this.getNextHighestDepth()) Var silenceLevel_nstep:mx.controls.NumericStepper Var silenceLevel_pb:mx.controls.ProgressBar