我正在使用此代码使用该ENTER_FRAME
功能检测鼠标的速度。鼠标的速度会影响我正在循环播放的 mp3。通过使用ENTER_FRAME
它通过帧速率进行更新,并使音乐听起来非常卡顿和混乱。
有没有办法减轻音量(仍在使用ENTER_FRAME
)或者我的 mp3 总是会受到这种影响?
var mySound1:Sound = new Sound();
mySound1.load(new URLRequest("AStringsMinor.mp3"));
var myChannel1:SoundChannel = new SoundChannel();
var myTransform1:SoundTransform = new SoundTransform();
myChannel1 = mySound1.play(0, 999);
var prevPt:Point = new Point(mouseX, mouseY);
addEventListener(Event.ENTER_FRAME, mouseSpeed);
function mouseSpeed(e:Event)
{
var xspeed:Number = Math.abs(mouseX - prevPt.x);
var yspeed:Number = Math.abs(mouseY - prevPt.y);
var speed:Number = (xspeed + yspeed) / 100;
prevPt = new Point(mouseX, mouseY);
myChannel1.soundTransform = myTransform1;
myTransform1.volume = speed;
}