将多个影片剪辑合并为一个影片剪辑

发布于 2024-08-10 01:52:34 字数 153 浏览 4 评论 0原文

我将多个视频存储为 MovieClip 对象,并希望将它们合并到单个 MovieClip 视频对象中,以便按顺序播放所有视频(以便用户认为这是一个视频)。

多谢!

编辑:我想在 Flash Player 内的 ActionScript 中以编程方式执行此操作。

I've multiple videos stored as MovieClip objects and would like to merge them into a single MovieClip video object in order to play all of them in sequence (so that a user thinks it's a single video).

Thanks a lot!

EDIT: I want to do it programmatically in ActionScript inside the Flash Player.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

烟若柳尘 2024-08-17 01:52:34

如果有 TIMELINE_COMPLETE 事件就太好了。但没有!因此,下一个最好的方法是未记录的 addFrameScript 方法。

您可以使用 addFrameScript() 将代码添加到 MovieClip 的最后一帧(或任何其他帧)。此代码可以删除旧的 MovieClip(刚刚完成的),并添加新的 MovieClip(队列中的下一个)。

public function Main() 
{
    // Remember addFrameScript() is zero based.
    currentVidMc.addFrameScript(currentVidMc.totalFrames - 1, frameFunction);
}

private function frameFunction():void 
{
    //delete frame script by passing null as second parameter
    currentVidMc.addFrameScript(currentVidMc.totalFrames - 1, null);

    removeChild(currentVidMc);
    addChild(newVidMc);
    newVidMc.gotoAndPlay(1);
}

编辑*

为了实现平滑过渡,您可以尝试尽早加载新剪辑(大约 15 帧对我来说听起来不错,但您必须尝试),将可见设置为 false,然后停止。然后,当当前剪辑的最后一帧滚动时,只需删除当前剪辑,并将新剪辑的可见属性设置为 true,然后播放即可。大部分跳转来自将剪辑加载到舞台,因此预渲染剪辑可能会有所帮助。

Would be great if there was a TIMELINE_COMPLETE event. But there isn't! So the next best thing is the undocumented addFrameScript method.

You can use addFrameScript() to add code to the last frame of your MovieClips (or any other frame). This code could remove the old MovieClip (the one that has just finished), and add the new MovieClip (the next one in the queue).

public function Main() 
{
    // Remember addFrameScript() is zero based.
    currentVidMc.addFrameScript(currentVidMc.totalFrames - 1, frameFunction);
}

private function frameFunction():void 
{
    //delete frame script by passing null as second parameter
    currentVidMc.addFrameScript(currentVidMc.totalFrames - 1, null);

    removeChild(currentVidMc);
    addChild(newVidMc);
    newVidMc.gotoAndPlay(1);
}

EDIT*

To make a smooth transition, you could try loading in the new clip early (about 15 frames sounds good to me, but you will have to try) with visible set to false, and stopped. Then when the last frame of the current clip rolls around, just remove the current clip, and set the new clips visible property to true, and play it. Most of the jump comes from the loading of the clip to the stage, so pre-rendering the clip may help.

涙—继续流 2024-08-17 01:52:34

这并不是一个真正的答案,但有两件事你也许可以尝试。

package {
    import flash.display.MovieClip;
    import flash.events.Event;

    public class OneMovieToRuleThemAll extends MovieClip {

        public subClips:Array; //vector for cs4
        private var index:int = 0;

        public function OneMovieToRuleThemAll(subClips:Array) {
            this.subClips = subClips;
        }

        //pre subClips.length > 0
        public function playAll() {
            for(var i:int = 0; i < subClips.length; i++) {
                subClips[i].visible = i == 0;
                subClips[i].stop();
                addChild(subClips[i]);
            }
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }

        private function onEnterFrame(e:Event) {
            if(index >= subClips.length) {
                //dispatchEvent finished
                removeEventListener(Event.ENTER_FRAME, onEnterFrame);
            }

            if(subClips[index].currentFrame < subClips[index].totalFrames) {
                subClips[index].gotoAndStop(subClips[index].currentFrame + 1);
            }else{
                subClips[index].visible = false;
                index++;
                subClips[index].visible = true;
            }

        }
    }

}

通常不鼓励使用 Enter_Frame 和 gotoAndStop(currentFrame) 因为它很慢,但也许这对于每个帧来说同样慢,所以你不会注意到任何“缝合”

另一种选择是为每个帧的每个帧构建一个带有位图的新影片剪辑电影与 BitmapData.draw(..);然后使用相同的 Enter_frame 循环并切换每个帧的可见属性。
可能会使用内存分配,我不知道它在速度方面是否可行。

Not really an answer but 2 things you could perhaps try.

package {
    import flash.display.MovieClip;
    import flash.events.Event;

    public class OneMovieToRuleThemAll extends MovieClip {

        public subClips:Array; //vector for cs4
        private var index:int = 0;

        public function OneMovieToRuleThemAll(subClips:Array) {
            this.subClips = subClips;
        }

        //pre subClips.length > 0
        public function playAll() {
            for(var i:int = 0; i < subClips.length; i++) {
                subClips[i].visible = i == 0;
                subClips[i].stop();
                addChild(subClips[i]);
            }
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }

        private function onEnterFrame(e:Event) {
            if(index >= subClips.length) {
                //dispatchEvent finished
                removeEventListener(Event.ENTER_FRAME, onEnterFrame);
            }

            if(subClips[index].currentFrame < subClips[index].totalFrames) {
                subClips[index].gotoAndStop(subClips[index].currentFrame + 1);
            }else{
                subClips[index].visible = false;
                index++;
                subClips[index].visible = true;
            }

        }
    }

}

It's usually discouraged to use enter_Frame and gotoAndStop(currentFrame) because it's slow, but maybe this is equally slow for each frame so you wont notice any 'stitching'

An alternative could also be to build a new movieclip with a Bitmap for each frame of each movie with BitmapData.draw(..); Then use the same enter_frame loop and toggle visible properties for each frame.
Probably uses allot of memory and I have no idea if it's even remotely feasible speed wise.

云仙小弟 2024-08-17 01:52:34

如果我是你,我会写一个简单的包装,它只是:
* 从某些 xml 配置中了解要显示的文件顺序
* 播放第一个文件时测量 fps(或可用 RAM 或互联网连接 - 取决于您如何将文件传输到播放 vedia 的电脑)
* 当最后包装器决定将第二个文件加载到某个可播放百分比的预计时间的 200%-300% 时。
* 如果你的预测算法足够酷 - 你会在第一个视频停止之前看到第二个视频。所以这是最简单的部分恕我直言[如果你的最后一帧和第一帧匹配得足够好]:你只需将第二个视频暂停在你需要的帧上并将其 alpha 设置为 0 将其放置在第一个视频下方。当第一个帧到达匹配帧时,您开始减少它的 alpha 值,增加第二个帧的 alpha 值,并将其从暂停中释放。

唯一的人工任务(除了对包装器进行编码之外,但感觉就像最多几个屏幕的代码)是搜索匹配的帧并将其全部放入配置中,但您甚至可以通过使用 BitmapData 来避免它。比较()方法。祝你好运!

if i were you i'd wright a simple wrapper it'd just:
* know the order of files to show from some xml config
* while playing the first file measure fps (or available RAM or internet connection - depends on how you deliver your files to the pc playing vedia)
* when at last the wrapper decides that it's just 200%-300% of the prognosed time of loading the second file to some playable percentage.
* if your prognosing algorithm is cool enough - you have the second vid before the first stopped. so here is the easiest part imho [if your last and first frames match good enough]: you just pause the second vid on the frame you need and set its' alpha to 0 placing it under the first one. when the first one comes to the matching frame you start decreasing it's alpha increasing the second ones' instead and releasing it from the pause.

the only human task (except of coding the wrapper, but it feels just like a couple of screens of code maximum) is searching for matching frames and putting it all to config, but you can avoid even it by using the BitmapData.compare() method. good luck!

画骨成沙 2024-08-17 01:52:34

将它们依次添加到时间线中,确保每个影片剪辑在时间线上的存在时间与它所包含的影片的持续时间一样长。您可以通过将关键帧添加到包含影片剪辑的时间轴来完成此操作。另外,请确保您的视频帧速率和 Flash 播放器帧速率相同。

这实际上不是一个编程问题。

Add them to the timeline one after another, make sure each movieclip exists on the timeline for as long as the duration of the movie it contains is. You can do this by adding keyframes to the timeline that will contain the movieclips. Also, make sure your video framerate and Flash player framerate are the same.

This isn't really a programming question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文