I want to loop some video in flash, I found this code but get "Access of possible undefined property COMPLETE through a reference with static type Class" when I try to run it.
video.source="video.flv";
import fl.video.*;
function onFLVCOMPLETE(event:VideoEvent):void{
event.target.play();
}
video.addEventListener(VideoEvent.COMPLETE, onFLVCOMPLETE);
No clue what is going on so any help would be great
EDIT
This is what is happening:
The FlashPro/AdobeAnimate IDE automatically imports the flash.events
package (whether or not you've explicitly told it to). When it does this, the flash.events.VideoEvent
class replaces your imported fl.video.VideoEvent
class as what is referenced when you use VideoEvent
.
To remedy this, you just need to use the fully qualified class name. So instead of using:
VideoEvent
You use:
fl.video.VideoEvent
So your code should look like this:
function onFLVCOMPLETE(event:fl.video.VideoEvent):void{
event.target.play();
}
video.addEventListener(fl.video.VideoEvent.COMPLETE, onFLVCOMPLETE);
To test this behavior, you create a new FlashPro project with following code on the timeline: (you'll also need to add a video component to the library)
import fl.video.VideoEvent;
trace(flash.utils.getQualifiedClassName(VideoEvent));
The expected result in the output window is fl.video::VideoEvent
, but the actual result is:
flash.events::VideoEvent
So even though you only imported fl.video.VideoEvent
, VideoEvent
is referring to flash.events.VideoEvent
(which was NOT imported).