基本上我有一个非常简单的视频库设置。我想要它,这样当视频暂停时,一些按钮将在屏幕上可见,而在播放时这些按钮将不可见。这是我的代码:
import fl.video.*;
import fl.video.VideoEvent;
import flash.events.Event;
videoOne.addEventListener(Event.PLAYING_STATE_ENTERED, hideInfo());
videoOne.addEventListener(Event.PAUSED_STATE_ENTERED, showInfo());
function showInfo() {
thumbnailOne.visible = true;
thumbnailTwo.visible = true;
thumbnailThree.visible = true;
videoGalleryInfo.visible = true;
infoHidden = 0;
}
function hideInfo() {
thumbnailOne.visible = false;
thumbnailTwo.visible = false;
thumbnailThree.visible = false;
videoGalleryInfo.visible = false;
infoHidden = 1;
}
我尝试使用 Event 而不是 VideoEvent 等等,因为这解决了之前为 COMPLETE 事件添加另一个事件侦听器的问题,但我总是返回
Video gallery, Layer 'ActionScript', Frame 77, Line 22 1119: Access of possibly undefined property PLAYING_STATE_ENTERED through a reference with static type Class.
Video gallery, Layer 'ActionScript', Frame 77, Line 23 1119: Access of possibly undefined property PAUSED_STATE_ENTERED through a reference with static type Class.
我不明白我做错了什么。不应该通过导入 fl.video.* 来定义属性吗?和 flash.events.Event;?
编辑:如果它很重要,这是我针对这个特定场景的其余代码,包括 null 建议的修复。我仍然收到相同的错误,加上“1136:参数数量不正确。预期为 1”错误
import flash.events.MouseEvent;
import fl.video.*;
import fl.video.VideoEvent;
import flash.events.Event;
stop();
homeButton.addEventListener(MouseEvent.CLICK, homePressed);
soundButton.addEventListener(MouseEvent.CLICK, soundPressed);
helpButton.addEventListener(MouseEvent.CLICK, helpPressed);
exitButton.addEventListener(MouseEvent.CLICK, exitPressed);
var videoPlaying:int = 0;
var infoHidden:int = 0;
videoOne.addEventListener(Event.COMPLETE, vid1Comp);
function vid1Comp(event:Event) {
videoOne.visible = false;
showInfo();
}
videoOne.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, hideInfo);
videoOne.addEventListener(VideoEvent.PAUSED_STATE_ENTERED, showInfo);
function showInfo(e:Event):void {
thumbnailOne.visible = true;
thumbnailTwo.visible = true;
thumbnailThree.visible = true;
videoGalleryInfo.visible = true;
infoHidden = 0;
}
function hideInfo(e:Event):void {
thumbnailOne.visible = false;
thumbnailTwo.visible = false;
thumbnailThree.visible = false;
videoGalleryInfo.visible = false;
infoHidden = 1;
}
thumbnailOne.addEventListener(MouseEvent.CLICK, playVid1);
function playVid1(event:MouseEvent) {
hideInfo();
if (musicPlaying == 1) {
SoundMixer.stopAll();
musicPlaying = 0;
}
videoOne.visible = true;
videoOne.play();
videoPlaying = 1;
}
videoOne.visible = false;