MovieClip.attachAudio()
Availability
Flash Player 6; the ability to attach audio from Flash Video (FLV) files was added in Flash
Player 7.
Usage
my_mc.attachAudio(source:Object) : Void
Parameters
The object containing the audio to play. Valid values are a Microphone object, a
source
NetStream object that is playing an FLV file, and
Returns
Nothing.
Description
Method; specifies the audio source to be played. To stop playing the audio source, pass
for
.
source
You can extend the methods and event handlers of the MovieClip class by creating a subclass. For
more information, see "Assigning a class to a movie clip symbol" in Using ActionScript in Flash.
Example
The following code creates a new NetStream connection. Add a new Video symbol by opening
the Library panel and selecting New Video from the Library options menu. Give it the instance
name
. Dynamically load the FLV video at runtime. Use the
my_video
attach the audio from the FLV file to a movie clip on the Stage. Then you can control the audio in
the movie clip using the Sound class and two buttons called
var my_nc:NetConnection = new NetConnection();
my_nc.connect(null);
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_ns.play("yourVideo.flv");
this.createEmptyMovieClip("flv_mc", this.getNextHighestDepth());
flv_mc.attachAudio(my_ns);
var audio_sound:Sound = new Sound(flv_mc);
// add volume buttons
volUp_btn.onRelease = function() {
if (audio_sound.getVolume()<100) {
audio_sound.setVolume(audio_sound.getVolume()+10);
updateVolume();
}
};
volDown_btn.onRelease = function() {
if (audio_sound.getVolume()>0) {
audio_sound.setVolume(audio_sound.getVolume()-10);
updateVolume();
}
};
(stops playing the audio).
false
attachAudio()
volUp_btn
MovieClip.attachAudio()
false
method to
and
:
volDown_btn
495
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers