我创建了一个带有滑动音量控制的小型音乐播放器。我的音量有问题。虽然它确实可以正确控制音量,但如果我将初始音量设置为小于 100%,则音量总是从 100% 开始,直到我将鼠标移到播放器上。此时,音量将更改为初始音量设置。
这是一个闪存错误,还是我错过了什么?
这是受影响的代码(为简洁起见,省略了其他按钮/功能的代码):
var song_initvolume:Number = 100;
slider_1._x = groove_1._x + song_initvolume;
playSong(0,song_play);
slider_1.onPress = function() {
this.startDrag(true, groove_1._x, groove_1._y, groove_1._x + 96, groove_1._y);
}
slider_1.onRelease = function() {
this.stopDrag();
}
slider_1.onMouseMove = function(){
newPoint = new Object();
newPoint.x = this._x;
newPoint.y = this._y;
groove_1.globalToLocal(newPoint);
mySound_sound.setVolume(-1 * newPoint.x);
}
function playSong(songNum,songPlay,reset_Pos){
if(reset_Pos){
mySound_sound = new Sound();
}
var myTitle = mySongs_array[songNum].TITLE;
trace("Playing TITLE= " + myTitle);
var myArtist = mySongs_array[songNum].ARTIST;
trace("Playing ARTIST= " + myArtist);
var myURL = mySongs_array[songNum].URL;
trace("Playing URL= " + myURL);
title_txt.text = mySongs_array[songNum].TITLE;
artist_txt.text = mySongs_array[songNum].ARTIST;
mySound_sound.loadSound(myURL,songPlay);
// start oncomplete
mySound_sound.onSoundComplete = function() {
song_pos = 0;
reset_Pos = true;
if(song_continuous){
song_play = true;
current_song++;
if (current_song>=my_total){
current_song=0;
if(song_loop){
song_play = true;
} else {
song_play = false;
}
}
} else {
song_play = false;
}
playSong(current_song,song_play,reset_Pos);
}
// end oncomplete
}
我希望能够将音量设置为 50%,但上述行为每次都会发生。
任何想法都非常感谢。