Reputation: 2901
hi i am using FLVPlayback 2.5 component and getting this error, please help! - cannot convert fl.video: to flash.events.VideoEvent.
as3 code using -
comp.addEventListener(Event.COMPLETE, videoComplete);
function videoComplete(event:VideoEvent):void {
trace("videoComplete");
}
full error -
TypeError: Error #1034: Type Coercion failed: cannot convert fl.video::VideoEvent@6e974dd1 to flash.events.VideoEvent. at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at fl.video::FLVPlayback/http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::httpDoStopAtEnd() at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::httpNetStatus()
fix thanks to ronnie! cheers man. this works for me..
import fl.video.VideoEvent;
comp.addEventListener(Event.COMPLETE, videoComplete);
function videoComplete(event:Event):void {
trace("videoComplete");
}
Upvotes: 0
Views: 9791
Reputation: 1716
I made a comment up there but I wanted to give you a full explaination here. When you said:
addEventListener(Event.COMPLETE, videoComplete);
it does in fact call your function... but with a different event than you expect. This is because it is actually firing a fl.video.VideoEvent which ALSO has a constant called COMPLETE. Both Event.COMPLETE and VideoEvent.COMPLETE = a string value "complete" so it calls you function.
Second problem is the function:
function videoComplete(event:VideoEvent):void {
is listening for a flash.events.VideoEvent. This was probably an accident when you used the code complete. But when you function get called, it is receiving a fl.video.VideoEvent... thus the error
so do these:
import fl.video.VideoEvent;
addEventListener(VideoEvent.COMPLETE, videoComplete);
function videoComplete(event:VideoEvent):void {
And you are all set!
Upvotes: 2
Reputation: 11198
lostPixels was right for the most part in explaining what the error means but it isn't VideoEvent
, its simply Event
comp.addEventListener(Event.COMPLETE, videoComplete);
function videoComplete(event:Event):void //event:Event not event:VideoEvent
{
trace("videoComplete");
}
Upvotes: 4
Reputation: 3851
You could add a cue point to the end of your video and listen for that.
Assuming comp is the instance name of your flvPlayback component...
import fl.video.FLVPlayback;
import fl.video.MetadataEvent;
comp.addEventListener(MetadataEvent.CUE_POINT, video_cp_listener, false, 0, true);
function video_cp_listener(eventObject:MetadataEvent):void {
//run code here when a cue point is found
trace(eventObject.info.name);
}
Upvotes: 1
Reputation: 1343
Type Coercion fails are the result of you trying to convert one strictly typed variable to another. What that means (it's not written to be easily understandable) is this:
Say we have two variables, one is a number, and one is a string. If we try and say number = string, Flash will spit out that error, because a string can't be a number.
What this has to do with your code is that you're trying to convert an Event to a VideoEvent.
To remedy this, change your code to this line:
comp.addEventListener(VideoEvent.COMPLETE, videoComplete);
Upvotes: 1
Reputation: 3851
I think this might have something to do with the flash player version you are targeting. Can you target FP9 or FP10? (in the properties panel in Flash Professional)
Upvotes: 1