as3 中的channel.position永远不等于sound.length
var snd:Sound = new Sound();
var t:Timer = new Timer(100);
var sndChannel:SoundChannel;
snd.addEventListener(Event.COMPLETE,onComplete);
t.addEventListener(TimerEvent.TIMER,onTimer);
snd.load(new URLRequest('some.mp3'));
function onComplete(e:Event):void
{
sndChannel = snd.play();
t.start();
sndChannel.addEventListener(Event.SOUND_COMPLETE,onSndComplete);
}
function onTimer(e:TimerEvent):void
{
trace(sndChannel.position/snd.length); // less than 1
}
function onSndComplete(e:Event):void
{
trace(sndChannel.position/snd.length); // also less than 1
}
/- 谁能告诉我为什么'sndChannel.position/snd.length'总是小于1? 这是一个错误吗? 如何修复这个错误? 谢谢... -/
var snd:Sound = new Sound();
var t:Timer = new Timer(100);
var sndChannel:SoundChannel;
snd.addEventListener(Event.COMPLETE,onComplete);
t.addEventListener(TimerEvent.TIMER,onTimer);
snd.load(new URLRequest('some.mp3'));
function onComplete(e:Event):void
{
sndChannel = snd.play();
t.start();
sndChannel.addEventListener(Event.SOUND_COMPLETE,onSndComplete);
}
function onTimer(e:TimerEvent):void
{
trace(sndChannel.position/snd.length); // less than 1
}
function onSndComplete(e:Event):void
{
trace(sndChannel.position/snd.length); // also less than 1
}
/-
Can anybody tell me why 'sndChannel.position/snd.length' always less than 1?
Is this a bug?
How to fix this bug?
Thanks...
-/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对真正的问题是什么感到困惑,但例如 sndChannel.position 的范围可以在 1 到 100 之间(只是示例)。在此示例中,snd.length 将为 100。因此,您可以得到位置,例如 50 除以 100,得到的结果是 0.5,小于 1。这意味着您已完成声音剪辑的 50%。我在这里没有看到任何错误或问题?你想达到什么目的?
哎呀,只需阅读标题...发布跟踪,值是什么?
i am confused as to what the real problem is, but for example sndChannel.position can for example range between 1 and 100 (just example). and snd.length in this example would be 100. so you get position for example 50 divided by 100 it gives you 0.5 which is less than 1. which means that you are 50% through the sound clip. I dont see any bug here or issues? what are you trying to achieve?
woops, just read the title... post the trace, what are the values?