嗨其他程序员,
我希望默认的videoPlayer停止或暂停。我如何在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);
}
}
}
提前谢谢!
答案 0 :(得分: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);