Archive for July 25th, 2008

25
Jul

Create an FLV thumbnail image from VideoDisplay during runtime in Flex

Here’s a Little trick that shows you how to generate an image thumbnail during runtime from a VideoDisplay component, you can than create a server side proxy to save the image as a file or just use it as it is. Enjoy.


    <mx:Script>
        <![CDATA[
			import mx.events.VideoEvent;

			private function playheadUpdateHandler(event:VideoEvent):void {

			    var bmData:BitmapData = new BitmapData(100, 100);
			    bmData.draw(event.target as DisplayObject);

			    var bm:Bitmap = new Bitmap(bmData);
			    img.source = bm;
			}
        ]]>
    </mx:Script>

    <mx:Canvas>

		<mx:VideoDisplay id="videoDisplay"
			source="someFlvVideo.flv"
			playheadUpdate="playheadUpdateHandler(event); event.target.stop();"
			visible="false" width="100" height="100" />
		<mx:Image id="img" />
    </mx:Canvas>