Might as well include this
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="initApp()">
<mx:Script>
<![CDATA[
private function initApp():void
{
myConsumer.subscribe();
onTimerComplete();
}
private function onTimerComplete():void
{
var asyncMessage:AsyncMessage = new AsyncMessage();
asyncMessage.headers.gatewayid="BlogStats";
asyncMessage.body={user:"b"};
myProducer.send(asyncMessage);
}
private function onMessageRecieved(event:MessageEvent):void
{
trace(event);
}
]]>
</mx:Script>
<mx:Consumer id="myConsumer" destination="ColdFusionGateway"
message="onMessageRecieved(event)" fault="mx.controls.Alert.show(event.faultString)" />
<mx:Producer id="myProducer" destination="ColdFusionGateway" fault="mx.controls.Alert.show(event.faultString)"/>
</mx:Application>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="initApp()">
<mx:Script>
<![CDATA[
private function initApp():void
{
myConsumer.subscribe();
onTimerComplete();
}
private function onTimerComplete():void
{
var asyncMessage:AsyncMessage = new AsyncMessage();
asyncMessage.headers.gatewayid="BlogStats";
asyncMessage.body={user:"b"};
myProducer.send(asyncMessage);
}
private function onMessageRecieved(event:MessageEvent):void
{
trace(event);
}
]]>
</mx:Script>
<mx:Consumer id="myConsumer" destination="ColdFusionGateway"
message="onMessageRecieved(event)" fault="mx.controls.Alert.show(event.faultString)" />
<mx:Producer id="myProducer" destination="ColdFusionGateway" fault="mx.controls.Alert.show(event.faultString)"/>
</mx:Application>
----- Original Message ----
From: Sherif Abdou <sherif626@...>
To: flexcoders@yahoogroups.com
Sent: Sunday, July 6, 2008 1:55:42 PM
Subject: [flexcoders] Flex Messaging
From: Sherif Abdou <sherif626@...>
To: flexcoders@yahoogroups.com
Sent: Sunday, July 6, 2008 1:55:42 PM
Subject: [flexcoders] Flex Messaging
All right so what I am doing wrong here, I am using the DataMessaging service in Coldfusion and everything works. However, I can not seem to return anything from the CFC other than the event itself. So for the first one am i not allowed to do that? All I want to do is send different information back than what flex is sending me.
This does not work
<cfcomponent output="false">
<cffunction name="onIncomingMes sage" access="remote" returntype=" struct">
<cfargument name="event" required="true" type="struct">
<cfset myStruct=StructNew( )>
<cfset myStruct.test= "Hello">
<cfreturn myStruct>
</cffunction>
</cfcomponent>
This works.
<cfcomponent output="false">
<cffunction name="onIncomingMes sage" access="remote" returntype=" struct">
<cfargument name="event" required="true" type="struct">
<cfset myStruct = event.data>
<cfreturn myStruct>
</cffunction>
</cfcomponent>
This does not work
<cfcomponent output="false">
<cffunction name="onIncomingMes sage" access="remote" returntype=" struct">
<cfargument name="event" required="true" type="struct">
<cfset myStruct=StructNew( )>
<cfset myStruct.test= "Hello">
<cfreturn myStruct>
</cffunction>
</cfcomponent>
This works.
<cfcomponent output="false">
<cffunction name="onIncomingMes sage" access="remote" returntype=" struct">
<cfargument name="event" required="true" type="struct">
<cfset myStruct = event.data>
<cfreturn myStruct>
</cffunction>
</cfcomponent>