【问题标题】:channel.position never equal sound.length in as3在 as3 中,channel.position 永远不会等于 sound.length
【发布时间】:2011-10-27 19:10:34
【问题描述】:
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? 这是一个错误吗? 如何修复此错误? 谢谢... -/

【问题讨论】:

  • 我无法在 CS4 中使用 3 秒 mp3 重现此测试。在 soundComplete 处理程序中,跟踪返回 1,每个后续计时器事件也是如此。是否有其他因素影响您的输出?

标签: flash audio position channel


【解决方案1】:

我对真正的问题是什么感到困惑,但例如 sndChannel.position 的范围可以在 1 到 100 之间(仅作为示例)。并且 snd.length 在这个例子中是 100。所以你得到的位置例如 50 除以 100 它给你 0.5 小于 1。这意味着你通过声音剪辑的 50%。我在这里没有看到任何错误或问题?你想达到什么目的?

哎呀,看看标题...发布跟踪,值是什么?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-07
    • 2019-05-21
    • 1970-01-01
    • 1970-01-01
    • 2015-12-02
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多