Basically I have a very simple video gallery set up. I want it so that when the video is paused some buttons will become visible on the screen and when it is playing these buttons will not be visible. This is my code:
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;
}
I have tried using Event instead of VideoEvent and so on as this fixed an issue with adding another event listener earlier on for the COMPLETE event, but I'm always returned with
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.
I do not understand what I'm doing wrong. Shouldn't the properties be defined through importing fl.video.*; and flash.events.Event;?
EDIT: In case it matters, here is the rest of my code for this particular scene, including the fixes that null suggested. I still get the same errors, plus a "1136: Incorrect number of arguments. Expected 1" error
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;
I found that to fix this issue you have to use the full path for the event, so changing
videoOne.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, hideInfo);
videoOne.addEventListener(VideoEvent.PAUSED_STATE_ENTERED, showInfo);
to
videoOne.addEventListener(fl.video.VideoEvent.PLAYING_STATE_ENTERED, hideInfo);
videoOne.addEventListener(fl.video.VideoEvent.PAUSED_STATE_ENTERED, showInfo);
fixed it. Pretty simple, really. Thank you for your help regardless, @null.