製作卡拉OK 或音樂動畫時,聲音與歌詞同步是關鍵。本文介紹三種不同難度與適用情境的同步方法。
總幀數 = 播放秒數 × 影格率(如 16.8 秒 × 12 fps ≈ 200 幀)。myMusic。stop();。onClipEvent (load) {
music = new Sound();
music.attachSound("myMusic");
music.start();
inc = 0;
timerStart = getTimer();
// 每句歌詞出現的時間(秒),可用 Media Player 量取
labelTimeList = [4, 8, 11, 15];
}
onClipEvent (enterFrame) {
if (getTimer() - timerStart > labelTimeList[inc] * 1000) {
inc++;
_root.nextFrame(); // 跳到下一幀顯示下一句歌詞
}
}
優點:不受時間軸長度限制、可精確控制毫秒級同步、方便加入互動(如點擊跳轉)。