![MACROMEDIA COLDFUSION MX 7.0.2-USING COLDFUSION MX WITH FLEX... Use Manual Download Page 31](http://html1.mh-extra.com/html/macromedia/coldfusion-mx-7-0-2-using-coldfusion-mx-with-flex/coldfusion-mx-7-0-2-using-coldfusion-mx-with-flex_use-manual_3298315031.webp)
Create the Flex application
31
Verify that your code is correct
Your code should match the following code example. Verify that the content is correct.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="initApp()">
<mx:Script>
<![CDATA[
import
mx.messaging.events.*;
import
mx.messaging.Producer;
import mx.messaging.messages.AsyncMessage;
public var pro:mx.messaging.Producer;
public var con:mx.messaging.Consumer;
public function initApp() {
pro = new mx.messaging.Producer();
pro.destination = "ColdFusionGateway";
consumer.subscribe();
}
public function sendMessage():void {
var msg:AsyncMessage = new AsyncMessage();
msg.headers.gatewayid = "Flex2CF2";
msg.body = new Object();
msg.body.emailto = emailto.text;
msg.body.emailfrom = emailfrom.text;
msg.body.emailsubject = emailsubject.text;
msg.body.emailmessage = emailmessage.text;
pro.send(msg);
messagestatus.text = "Message sent to ColdFusion.";
}
private function messageHandler(event:MessageEvent):void {
messagestatus.text = "Message received from ColdFusion.";
}
]]>
</mx:Script>
<mx:Consumer id="consumer" destination="ColdFusionGateway"
message="messageHandler(event)" />