ActionScript 2.0 语言参考 |
|
|
|
| ActionScript 语言元素 > 全局函数 > stopAllSounds 函数 | |||
stopAllSounds() : Void
在不停止播放头的情况下停止 SWF 文件中当前正在播放的所有声音。设置到流的声音在播放头移过它们所在的帧时将恢复播放。
可用性:ActionScript 1.0、Flash Player 3
下面的代码会创建一个文本字段,在该字段中,会显示歌曲的 ID3 信息。将会创建一个新的 Sound 对象实例,并且要将您的 MP3 加载到 SWF 文件中。ID3 信息是从该声音文件中提取的。当用户单击 stop_mc, 时,声音会暂停。当用户单击 play_mc, 时,歌曲会从它暂停的位置继续播放。
this.createTextField("songinfo_txt", this.getNextHighestDepth, 0, 0, Stage.width, 22);
var bg_sound:Sound = new Sound();
bg_sound.loadSound("yourSong.mp3", true);
bg_sound.onID3 = function() {
songinfo_txt.text = "(" + this.id3.artist + ") " + this.id3.album + " - " + this.id3.track + " - "
+ this.id3.songname;
for (prop in this.id3) {
trace(prop+" = "+this.id3[prop]);
}
trace("ID3 loaded.");
};
this.play_mc.onRelease = function() {
/* get the current offset. if you stop all sounds and click the play button, the MP3 continues from
where it was stopped, instead of restarting from the beginning. */
var numSecondsOffset:Number = (bg_sound.position/1000);
bg_sound.start(numSecondsOffset);
};
this.stop_mc.onRelease = function() {
stopAllSounds();
};
|
|
|
|