Actionscript 3 如何在Flash CC中显示mp4然后暂停和重播
我正在恢复一个简单的横幅,其中我们使用了一个FLV电影和以下代码,使用setInterval让电影暂停,然后再次播放。这是一部简单的蝴蝶电影,拍打翅膀,然后回到静止状态 看起来在最近的Flash版本中不鼓励FLV,所以我想知道如何播放电影,然后使用setInterval暂停,然后重播 以下是在基于帧的动画中使用时间轴上的FLV,但不使用导入的。mp4:Actionscript 3 如何在Flash CC中显示mp4然后暂停和重播,actionscript-3,flash,Actionscript 3,Flash,我正在恢复一个简单的横幅,其中我们使用了一个FLV电影和以下代码,使用setInterval让电影暂停,然后再次播放。这是一部简单的蝴蝶电影,拍打翅膀,然后回到静止状态 看起来在最近的Flash版本中不鼓励FLV,所以我想知道如何播放电影,然后使用setInterval暂停,然后重播 以下是在基于帧的动画中使用时间轴上的FLV,但不使用导入的。mp4: stop(); function timesUp() { gotoAndPlay(1,"Scene 1"); clearInterval(
stop();
function timesUp()
{
gotoAndPlay(1,"Scene 1");
clearInterval(itv);
}
var itv=setInterval(timesUp, 15000);
新建议的方法是否使用单帧电影,在其中加载并播放mp4,然后使用setInterval作为计时器进行回放
我找不到任何以这种方法为例的教程
我确实在Adobe网站上读过一篇教程,但是下面的内容没有加载和播放电影morpho.mp4
var nc:NetConnection = new NetConnection();
nc.connect(null);
var vid:Video = new Video();
addChild(vid);
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
function netStatusHandler(event:NetStatusEvent):void
{
// handle netStatus events, described later
}
function asyncErrorHandler(event:AsyncErrorEvent):void
{
// ignore error
}
vid.attachNetStream(ns);
ns.play("morpho.mp4");
试试这个:
import flash.utils.Timer
import flash.events.TimerEvent
var video_playing:Boolean = false,
timer:Timer,
nc:NetConnection,
ns:NetStream,
video:Video,
video_name:String = 'video.mp4'
nc = new NetConnection()
nc.connect(null)
ns = new NetStream(nc)
ns.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code){
case 'NetStream.Play.Start' :
if(timer.currentCount == 0){
timer.start()
}
break
}
}
function asyncErrorHandler(event:AsyncErrorEvent):void {
}
video = new Video(135, 135) // set the size of video to 135x135px
video.x = 165 // set the left of video to 300 - 135 = 165px
video.y = 0 // set the top of video to 0
video.attachNetStream(ns)
addChild(video)
timer = new Timer(1000, 3) // 3 seconds, just for example
timer.addEventListener(TimerEvent.TIMER_COMPLETE, timer_on_Complete)
function timer_on_Complete(e:TimerEvent){
if(video_playing){
video_playing = false
ns.close()
} else {
start_video()
}
timer.reset()
timer.start()
}
start_video()
function start_video(){
ns.play(video_name)
video_playing = true
}
我测试了你的代码,它的工作没有问题。你能把traceevent.info.code添加到netStatusHandler中吗,可能是因为你的视频找不到了。akmzo-你是对的。非常感谢。我添加的跟踪显示.mp4与电影不在同一个/root目录中。它的工作,以显示虽然占了整个阶段,并把下一个问题,以如何整合设置间隔和重播?我试着做什么,你正在寻找。akmozo-工程完美。谢谢问题:mp4是135 x 135,位于300 x 135舞台的右侧。我在时间轴上的左侧有一个徽标,但现在mp4涵盖了这一点。我应该探索哪些代码来了解如何调整mp4的大小和位置?