Mega Code Archive

 
Categories / Flex / Graphics
 

Detect connection error when loading flv with VideoDisplay

<?xml version="1.0" encoding="utf-8"?> <mx:Application name="Test"         xmlns:mx="http://www.adobe.com/2006/mxml"         initialize="init();">     <mx:Script>                      import mx.controls.VideoDisplay;             import mx.controls.Alert;             import mx.events.VideoEvent;             private var videoDisplay:VideoDisplay;             private function init():void {                 videoDisplay = new VideoDisplay();                 videoDisplay.addEventListener(VideoEvent.STATE_CHANGE,onError);                 videoDisplay.source = "http://server.com/a.flv";                 addChild(videoDisplay);             }             private function onError(evt:VideoEvent):void {                 switch (evt.state) {                     case VideoEvent.CONNECTION_ERROR:                         evt.currentTarget.visible = false;                         Alert.show(evt.currentTarget.source, "Failed to connect to video");                         break;                 }             }            </mx:Script> </mx:Application>