The Image class is the proxy for the ColdFusion Image service, which provides the functionality of the cfimage tag. You specify the required cfimage attributes for the action as Image tag attributes. The following examples show typical usage, in this case adding a border:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
xmlns:cf="coldfusion.service.mxml.*" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import coldfusion.service.events.*;

function init():void
{
img.execute();
}

function handleResult(event:ColdFusionServiceResultEvent):void
{
mx.controls.Alert.show("result=" + event.result.toString());
retImage.source = event.result.toString();
}

function handleError(event:ColdFusionServiceFaultEvent):void
{
mx.controls.Alert.show(event.toString());
}
]]>
</mx:Script>

<cf:Config
id="configid"
cfServer="127.0.0.1"
cfPort="80"
servicePassword="service"
serviceUserName="service"/>

<!-- Add border-->
<cf:Image
id="img"
action="addborder"
color="red"
thickness="5"
source="http://127.0.0.1:80/GetExifmetaData.jpg"
result="handleResult(event)"
fault="handleError(event)"/>

<mx:Image id="retImage"/>
</mx:Application>

Batch operation

A batch operation lets you perform multiple image manipulations on an image as part of one operation, instead of performing the operations individually. You upload an image to the server, use the batch operation to perform multiple Image operations on it, and get the modified image back from the server. To use this action, use an associative array of actions and corresponding attributes. It is easier to create an associative array in ActionScript than MXML. 
The following example shows code to create the associative array with the action information and perform the batch operation: 
ActionScript Part:

[Bindable]
public var attributes:Array =
[{AddBorder:{color:"Red",thickness:"50"}},
{Resize:{width:"50%",height:"50%",interpolation:"blackman",blurfactor:"2"}},
{Flip:{transpose:"270"}}]

MXML Part:

<!-- batch operation --
<cf:Image id="img" action="batchoperation"
source="http://localhost:8500/cat.jpg"
attributes="{attributes}"/>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy