简体   繁体   English

如何加载包含FLV的MovieClip而不出现卡顿现象

[英]How do I load MovieClip containing FLV without stuttering

So I have var MC_1 which is Movieclip that contains FLV on its timeline. 因此,我有var MC_1 ,这是在时间轴上包含FLV Movieclip。 MC_1 is supposed to appear on screen when user presses SPACE . 当用户按下SPACE时, MC_1应该出现在屏幕上。 It is working, except that before MC_1 is done loading on screen, its almost played itself once, showing you last seconds and then starting its second loop. 它可以正常工作,只是在MC_1完成在屏幕上加载之前,它几乎自己播放过一次,向您显示最后几秒钟,然后开始第二次循环。

How do I make it so that it plays itself only when it has done loading? 我如何使它仅在完成加载后才能播放? Here's simplified code: 这是简化的代码:

package comm {

    import flash.display.*;
    import flash.events.*;
    import flash.ui.*;
    import flash.system.*;
    import comm.*;
    import comm.assets.*;

    public class main {

        public var MC_1:comm.assets.intro_video = new comm.assets.intro_video();
        public var cutscene_container:Sprite = new Sprite();

        public function main() {
            addChild(cutscene_container);
            stage.addEventListener(KeyboardEvent.KEY_DOWN, introstart_handler);

            function introstart_handler(event:KeyboardEvent){
                if(event.keyCode == 32){

                    cutscene_container.addChild(MC_1);
                    stage.removeEventListener(KeyboardEvent.KEY_DOWN, introstart_handler);

                }
            }
        }


    }
}

I hope I explained my question clearly enough :P Cheers! 我希望我已经足够清楚地解释了我的问题:P干杯!

Came up with solution to my problem. 解决了我的问题。 Thought it nice to share if anyone else is having same problem: 如果其他人遇到相同的问题,我认为很高兴与他人分享:

package comm {

    import flash.display.*;
    import flash.events.*;
    import flash.ui.*;
    import flash.system.*;
    import comm.*;
    import comm.assets.*;

    public class main {

        public var MC_1:comm.assets.intro_video = new comm.assets.intro_video();
        public var cutscene_container:Sprite = new Sprite();

        public function main() {
            addChild(cutscene_container);

            cutscene_container.addChild(MC_1);
            MC_1.visible = false;
            MC_1.gotoAndStop(1);

            stage.addEventListener(KeyboardEvent.KEY_DOWN, introstart_handler);


            function introstart_handler(event:KeyboardEvent){
                if(event.keyCode == 32){
                    MC_1.visible = true;
                    MC_1.gotoAndPlay(1);

                    stage.removeEventListener(KeyboardEvent.KEY_DOWN, introstart_handler);
                }
            }




        }


    }
}

MC_1 is added to stage/container, stopped and invisible before it is needed. MC_1已添加到平台/容器,在需要之前已停止且不可见。 When it is needed (SPACE button press here) it is made visible and it will be played from frame 1. 当需要它时(按一下SPACE按钮),它将变为可见,并从第1帧开始播放。

Hope this helps if anyone else is having trouble with stuttering animation in form of FLV inside a MovieClip. 如果其他人在MovieClip中以FLV形式进行口吃动画时遇到麻烦,希望这对您有所帮助。

It surely did solve my problem. 它确实解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM