ImageSnapshot でキャプチャ

by matsu
♥1 | Line 47 | Modified 2009-12-03 09:50:29 | MIT License
play

ActionScript3 source code

/**
 * Copyright matsu ( http://wonderfl.net/user/matsu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/h17k
 */

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
	layout="vertical"
	verticalAlign="middle"
	backgroundColor="white"
	creationComplete="init();">
	
	<mx:Script>
		<![CDATA[
			import mx.core.IUIComponent;
			import mx.graphics.ImageSnapshot;
			
			private function init():void
			{
				testList.dataProvider = myModel.item;
			}
			
			private function imageSnapshotButtonClick(source:IBitmapDrawable):void
			{
				var _bitmapData:BitmapData = ImageSnapshot.captureBitmapData(source);
				var _bitmap:Bitmap = new Bitmap(_bitmapData);
				testImage.addChild(_bitmap);
				
				var _imageSnapshot:ImageSnapshot = ImageSnapshot.captureImage(source);
				var imageByteArray:ByteArray = _imageSnapshot.data as ByteArray;
				testSWFLoader.load(imageByteArray);
			}
		]]>
	</mx:Script>
	
	<mx:Model id="myModel">
		<items>
			<item label="test1" data="hoge1"/>
			<item label="test2" data="hoge2"/>
			<item label="test3" data="hoge3"/>
			<item label="test4" data="hoge4"/>
			<item label="test5" data="hoge5"/>
		</items>
	</mx:Model>
	
	<mx:ApplicationControlBar dock="false">
		<mx:Button id="imageSnapshotButton" label="ImageSnapshot" click="imageSnapshotButtonClick(testList);" />
	</mx:ApplicationControlBar>
	
	<mx:HBox>
		<mx:List id="testList" width="100"/>
		<mx:Image id="testImage" width="100"/>
		<mx:SWFLoader id="testSWFLoader">
			<mx:filters>
				<mx:GlowFilter color="#009911" blurX="10" blurY="10"/>
			</mx:filters>
		</mx:SWFLoader>
	</mx:HBox>

</mx:Application>