flex3的encodeImageAsBase64()方法
转换为base-64 encoded格式的例子:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/07/converting-an-imagesnapshot-object-into-a-base-64-encoded-string-in-flex-3/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"> <mx:Script>
<![CDATA[
import flash.events.FocusEvent;
import flash.system.System;
import mx.graphics.ImageSnapshot; private function button_click(evt:MouseEvent):void {
var ohSnap:ImageSnapshot = ImageSnapshot.captureImage(img);
textArea.text = ImageSnapshot.encodeImageAsBase64(ohSnap);
} private function textArea_focusIn(evt:FocusEvent):void {
textArea.setSelection(0, textArea.text.length);
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:Button label="Capture and encode"
click="button_click(event);" />
</mx:ApplicationControlBar>
<mx:Form>
<mx:FormItem label="source:">
<mx:Image id="img"
source="@Embed('images/flex_logo.jpg')" />
</mx:FormItem>