控制外部类上的 FLVPLAY



嗨,程序员们,

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

Main.as

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");
            }
        }

video01.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);  
    }
}
} 

提前感谢!

如果您希望视频播放器从首次加载时暂停,则可以使用 .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 中,您可以选择在创建实例时将 startPlay 设置为 true 或 false。

var mc_video01:MovieClip = new video01(false);

相关内容

  • 没有找到相关文章

最新更新