<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/08/setting-a-default-encoder-for-the-imagesnapshot-class-in-flex-3/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
		layout="vertical"
		verticalAlign="middle"
		backgroundColor="white"
		creationComplete="init();" viewSourceURL="srcview/index.html">

	<mx:Script>
		<![CDATA[
			import mx.graphics.ImageSnapshot;
			import mx.graphics.codec.*;

			private function init():void {
				ImageSnapshot.defaultEncoder = PNGEncoder;
			}

			private function captureImg():void {
				var ohSnap:ImageSnapshot = ImageSnapshot.captureImage(img);
				textArea.text = ImageSnapshot.encodeImageAsBase64(ohSnap);
				lbl.text = ohSnap.contentType;
			}
		]]>
	</mx:Script>

	<mx:ApplicationControlBar dock="true">
		<mx:Button id="button"
				label="Capture Image"
				click="captureImg();" />
	</mx:ApplicationControlBar>

	<mx:Form>
		<mx:FormItem label="source:">
			<mx:Image id="img"
					source="@Embed('images/flex_logo.jpg')" />
		</mx:FormItem>
		<mx:FormItem label="Base64:">
			<mx:TextArea id="textArea"
					editable="false"
					width="320"
					height="160" />
		</mx:FormItem>
		<mx:FormItem label="contentType:">
			<mx:Label id="lbl" />
		</mx:FormItem>
	</mx:Form>

</mx:Application>

