0

各位程序员好,

我希望默认的 videoPlayer 被停止或暂停。如何在我的 Main.as 中控制它?在我按下 btn_1 之前,似乎视频正在后台播放。这是我的代码:

主文件

package 
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import fl.video.*;

public class Main extends MovieClip 
{
    var filmAan = false;

    public function Main() 
    {
        stop();

        trace( "hij werkt" ); 

        btn_1.addEventListener(MouseEvent.CLICK,speel1);
        btn_2.addEventListener(MouseEvent.CLICK,speel2);
        btn_3.addEventListener(MouseEvent.CLICK,speel3);
        btn_4.addEventListener(MouseEvent.CLICK,speel4);
        btn_5.addEventListener(MouseEvent.CLICK,speel5);
        btn_6.addEventListener(MouseEvent.CLICK,speel6);
        btn_7.addEventListener(MouseEvent.CLICK,speel7);
        btn_8.addEventListener(MouseEvent.CLICK,speel8);
        btn_9.addEventListener(MouseEvent.CLICK,speel9);

        var mc_video01:MovieClip = new video01();
        var mc_video02:MovieClip = new video02();
        var mc_video03:MovieClip = new video03();
        var mc_video04:MovieClip = new video04();
        var mc_video05:MovieClip = new video05();
        var mc_video06:MovieClip = new video06();
        var mc_video07:MovieClip = new video07();
        var mc_video08:MovieClip = new video08();
        var mc_video09:MovieClip = new video09();

        function speel1(evtObj:MouseEvent):void 
        {
            if (filmAan == false) 
            {
                trace("knop 1 werkt");              

                addChild(mc_video01);
                mc_video01.x=1020; 
                mc_video01.y=680;
                mc_video01.width=1360;
                mc_video01.height=1060;

                filmAan = true;
            }
            else
            {
                trace("knop 1 uitgeschakeld");
            }
        }

视频01.as:

package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import fl.video.*;

public class video01 extends MovieClip
{
    public function video01()
    {
        trace("movieclip 1 geladen");
        videoPlayer.source = "video/video01.flv";
        videoPlayer.play();

        btn_terug.addEventListener(MouseEvent.CLICK, terug);
    }

    public function terug(evt:MouseEvent):void 
    {
        trace("knop ingedrukt");
        videoPlayer.pause();
        Main(parent).filmAan = false;
        this.parent.removeChild(this);  
    }
}
} 

提前谢谢!

4

1 回答 1

0

如果您希望 videoPlayer 在首次加载时暂停,则可以使用 .autoplay 属性并将其设置为 false。

videoPlayer.autoplay=false;

如果你想从 Main.as 中暂停它的选项,你可以在调用它时向类添加一个参数......

...public function video01(startPlaying:Boolean=true)
{
    trace("movieclip 1 geladen");
    videoPlayer.source = "video/video01.flv";

    if(startPlaying==false)
    {
        videoPlayer.autoplay=false;
    }

    btn_terug.addEventListener(MouseEvent.CLICK, terug);
}...

然后在您的 main.as 中,您可以选择在创建实例时将 startPlaying 设置为 true 或 false。

var mc_video01:MovieClip = new video01(false);
于 2012-12-18T10:18:02.663 回答