# TypeError: Error #1034: Type Coercion failed

**URL:** <https://forum.kirupa.com/t/typeerror-error-1034-type-coercion-failed/234238>\
**Category:** flash\
**Created:** [July 31, 2007, 5:39pm UTC](https://forum.kirupa.com/t/typeerror-error-1034-type-coercion-failed/234238 "2007-07-31T17:39:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wvoets](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/wvoets/32/3904_2.png) [@wvoets](https://forum.kirupa.com/u/wvoets)\
**Post date:** [July 31, 2007, 5:39pm UTC](https://forum.kirupa.com/t/typeerror-error-1034-type-coercion-failed/234238/1 "2007-07-31T17:39:57Z")

</div>

Hey All,

I’m having some trouble with a video player.  
This is the code (I started with a tutorial from [adobe.com](http://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::dispatchEventFunction()  
> at flash.events::EventDispatcher/dispatchEvent()  
> at fl.video::FLVPlayback/[http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent()](http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent())  
> at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()  
> at flash.events::EventDispatcher/dispatchEvent()  
> at fl.video::VideoPlayer/[http://www.adobe.com/2007/flash/flvplayback/internal::httpDoStopAtEnd()](http://www.adobe.com/2007/flash/flvplayback/internal::httpDoStopAtEnd())  
> at fl.video::VideoPlayer/[http://www.adobe.com/2007/flash/flvplayback/internal::doUpdateTime()](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
