| Package | flash.media |
| Class | public final class SoundChannel |
| Inheritance | SoundChannel EventDispatcher Object |
stop() method,
properties for monitoring the amplitude (volume) of the channel, and a property for setting a
SoundTransform object to the channel.
See also
| Property | Defined by | ||
|---|---|---|---|
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | |
| leftPeak : Number
[read-only]
The current amplitude (volume) of the left channel, from 0 (silent) to 1 (full amplitude).
| SoundChannel | ||
| position : Number
[read-only]
The current position of the playhead within the sound.
| SoundChannel | ||
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
| rightPeak : Number
[read-only]
The current amplitude (volume) of the right channel, from 0 (silent) to 1 (full amplitude).
| SoundChannel | ||
| soundTransform : SoundTransform
The SoundTransform object assigned to the sound channel.
| SoundChannel | ||
| Method | Defined by | ||
|---|---|---|---|
![]() |
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event.
| EventDispatcher | |
![]() |
Dispatches an event into the event flow.
| EventDispatcher | |
![]() |
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event.
| EventDispatcher | |
![]() |
Indicates whether an object has a specified property defined.
| Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Removes a listener from the EventDispatcher object.
| EventDispatcher | |
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
|
Stops the sound playing in the channel.
| SoundChannel | ||
![]() |
Returns the string representation of the specified object.
| Object | |
![]() |
Returns the primitive value of the specified object.
| Object | |
![]() |
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type.
| EventDispatcher | |
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when a sound has finished playing. | SoundChannel | |||
| leftPeak | property |
leftPeak:Number [read-only]The current amplitude (volume) of the left channel, from 0 (silent) to 1 (full amplitude).
Implementation public function get leftPeak():Number
| position | property |
position:Number [read-only]The current position of the playhead within the sound. If the sound is looped, the position is reset to 0 at the beginning of each loop.
Implementation public function get position():Number
| rightPeak | property |
rightPeak:Number [read-only]The current amplitude (volume) of the right channel, from 0 (silent) to 1 (full amplitude).
Implementation public function get rightPeak():Number
| soundTransform | property |
soundTransform:SoundTransform [read-write]The SoundTransform object assigned to the sound channel. A SoundTransform object includes properties for setting volume, panning, left speaker assignment, and right speaker assignment.
Implementation public function get soundTransform():SoundTransform
public function set soundTransform(value:SoundTransform):void
See also
| stop | () | method |
public function stop():voidStops the sound playing in the channel.
| soundComplete | event |
flash.events.Event
flash.events.Event.SOUND_COMPLETE
Dispatched when a sound has finished playing.
Defines the value of the type property of a soundComplete event object.
This event has the following properties:
| Property | Value |
|---|---|
bubbles | false |
cancelable | false; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The Sound object on which a sound has finished playing. |
package {
import flash.display.Sprite;
import flash.events.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.utils.Timer;
public class SoundChannelExample extends Sprite {
private var url:String = "MySound.mp3";
private var soundFactory:Sound;
private var channel:SoundChannel;
private var positionTimer:Timer;
public function SoundChannelExample() {
var request:URLRequest = new URLRequest(url);
soundFactory = new Sound();
soundFactory.addEventListener(Event.COMPLETE, completeHandler);
soundFactory.addEventListener(Event.ID3, id3Handler);
soundFactory.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
soundFactory.addEventListener(ProgressEvent.PROGRESS, progressHandler);
soundFactory.load(request);
channel = soundFactory.play();
channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
positionTimer = new Timer(50);
positionTimer.addEventListener(TimerEvent.TIMER, positionTimerHandler);
positionTimer.start();
}
private function positionTimerHandler(event:TimerEvent):void {
trace("positionTimerHandler: " + channel.position.toFixed(2));
}
private function completeHandler(event:Event):void {
trace("completeHandler: " + event);
}
private function id3Handler(event:Event):void {
trace("id3Handler: " + event);
}
private function ioErrorHandler(event:Event):void {
trace("ioErrorHandler: " + event);
positionTimer.stop();
}
private function progressHandler(event:ProgressEvent):void {
trace("progressHandler: " + event);
}
private function soundCompleteHandler(event:Event):void {
trace("soundCompleteHandler: " + event);
positionTimer.stop();
}
}
}
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/2/langref/flash/media/SoundChannel.html
Comments
DGuy01 said on Sep 4, 2006 at 6:56 PM :