PDA

View Full Version : TypeError: Error #1034: Type Coercion failed



wvoets
July 31st, 2007, 02:39 PM
Hey All,

I'm having some trouble with a video player.
This is the code (I started with a tutorial from adobe.com, but the sample files from adobe suffer the same problem)


import fl.video.*;

// Define the variable for the video component instance name
var flvControl = display;

// Create the video playlist
var videoList = ["video1.flv","video2.flv","video3.flv","video4.flv"];
var videoIndex = 0;
var loopAtEnd = true;

// Handle the video completion (load the next video)
flvControl.addEventListener(VideoEvent.COMPLETE, completeHandler);

function completeHandler(event:MetadataEvent):void {
// Get next item in list
videoIndex++;

// Validate index
if (
videoIndex == videoList.length ) {
if ( loopAtEnd ) {
videoIndex = 0;
} else {
return;
}
}

// Load the next video
flvControl.source = videoList[videoIndex];
}

// Set the default video (Start)
flvControl.source = videoList[0];

// Next movie button
next_btn.addEventListener(MouseEvent.CLICK, nextMovie);
function nextMovie(event:MouseEvent):void {
// Get next item in list
videoIndex++;

// Validate index
if (
videoIndex == videoList.length ) {
if ( loopAtEnd ) {
videoIndex = 0;
} else {
return;
}
}

// Load the next video
flvControl.source = videoList[videoIndex];
}

// Controls
play_btn.addEventListener(MouseEvent.CLICK, btnPlay);
function btnPlay(event:MouseEvent):void {
display.play();
}
stop_btn.addEventListener(MouseEvent.CLICK, btnPause);
function btnPause(event:MouseEvent):void {
display.pause();
}

When the first movie ends, the second movie dousn't start, and I get the following error.


TypeError: Error #1034: Type Coercion failed: cannot convert fl.video::VideoEvent@494b9f59 to fl.video.MetadataEvent.
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at fl.video::FLVPlayback/http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
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::doUpdateTime()
at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
at flash.utils::Timer/flash.utils:Timer::tick()

Anyone any thoughts? Many thanks in advance.
Cheers, Wim

wvoets
August 2nd, 2007, 08:33 AM
Anyone? :(

senocular
August 2nd, 2007, 09:32 AM
well, lets see. It says "cannot convert fl.video::VideoEvent@494b9f59 to fl.video.MetadataEvent" ... so change MetadataEvent to VideoEvent

wvoets
August 2nd, 2007, 10:07 AM
Thanks again senocular! You're my hero! ;)

flashdaddy
October 16th, 2011, 12:00 AM
Nice, thanks for the post/response. This helped me figure out my issue.