开发者

Start video and play movie clip at the same time in Flash

Is it possible (in AS2 or AS3) to have a button that starts a video as well as an MC at the same time?

The idea being that 开发者_高级运维the video will play alongside a movieclip that contains animated quotes from the dialog of the video, so syncing would be critical to.


AS3.

i presume that you already have a videoPlayer or some netstream and metadata handlers. and you have all the needed items on the stage.

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 ));
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜