开发者

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

开发者 https://www.devze.com 2023-04-07 16:40 出处:网络
Is it possible (in AS2 or AS3) to have a button that starts a video as well as an MC at the same time?

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

精彩评论

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