在Flash中同时启动视频和播放影片剪辑

时间:2011-09-27 09:53:10

标签: flash actionscript-3 actionscript-2

是否可以(在AS2或AS3中)有一个按钮同时启动视频和MC?

这个想法是视频将与包含视频对话框中的动画引号的动画片段一起播放,因此同步将至关重要。

1 个答案:

答案 0 :(得分:0)

AS3。

我认为你已经拥有了一个videoPlayer或一些netstream和元数据处理程序。并且你在舞台上拥有所有需要的物品。

var playProgressTimer:Timer;
var movieClip:MovieClip;

function handlePlayButtonClicked ( e : MouseEvent ) : void
{
    playProgressTimer = new Timer(100);
    playProgressTimer.addEventListener(TimerEvent.TIMER, onPlayProgressTick);
    playProgressTimer.start ();
}

function onPlayProgressTick ( e : TimerEvent ) : void
{
if (!netStream || !metaData)
    return;
    // getting the progress of the video
    var _playProgress:Number = netStream.time / metaData.duration;
    // setting the same progress to the movieclip you have.
    movieClip.gotoAndStop(int(_playProgress * movieClip.totalFrames ));
}