기존 flex2에서 화면을 캡쳐하기 위해서는
클래스를 따로 만들어야했지만,
Flex3부터 기본 제공 ㅎㅎ
좋다!
<?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();">
<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>
http://blog.flexexamples.com/2007/12/08/setting-a-default-encoder-for-the-imagesnapshot-class-in-flex-3/
클래스를 따로 만들어야했지만,
Flex3부터 기본 제공 ㅎㅎ
좋다!
<?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();">
<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>
http://blog.flexexamples.com/2007/12/08/setting-a-default-encoder-for-the-imagesnapshot-class-in-flex-3/
'ria > flex' 카테고리의 다른 글
| embed 태크의 wmode (0) | 2008/03/17 |
|---|---|
| Flex Performance Tuning Tips (0) | 2008/03/17 |
| Flex3 이미지 캡쳐 (0) | 2008/03/07 |
| Flex Resources (0) | 2008/03/04 |
| [Flex] CSS를 Embed 하는 방법과 런타임시 적용하는 방법 예제 (0) | 2008/02/27 |
| Background pattern - Flex (0) | 2008/02/27 |


이올린에 북마크하기
이올린에 추천하기