2011-08-16 19 views
0
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? 這是一個錯誤? 如何解決這個錯誤? 謝謝... -/channel.position從來沒有在AS3等於sound.length

+0

我無法用CS4中的3秒鐘mp3重現此測試。在soundComplete處理程序中,跟蹤返回1,每個後續計時器事件都會返回。是否有可能影響你的輸出的其他因素? – shanethehat

回答

0

我很困惑,真正的問題是什麼,但例如sndChannel.position可以爲1和100(例如剛)之間的示例範圍。在這個例子中snd.length是100,所以你得到的位置例如是50除以100,它給你0.5小於1,這意味着你在聲音片段中佔50%。我沒有看到任何錯誤在這裏或問題?你想達到什麼目的?

woops,只是閱讀標題...張貼痕跡,有什麼價值?