Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Messaging w/ Complex Data Types


Level 1
Hey everyone,

I'm having issues trying to pass complex data type objects I
created using the BlazeDS messaging service.

To be more exact, I have an AC3 class "Cargo" that I wrote
that contains only five public properties of type 'String':
contents, length, width, height, and weight. The application I
wrote allows the user to enter these properties using text input
components, and then publishes the Cargo object through the
Producer.send() function.

Below is the pertinent code:

private function sendMessage():void {

var message:AsyncMessage = new AsyncMessage();

messageObj.contents = ti_contents.text; //messageObj is of
type 'Cargo'

messageObj.length = ti_length.text; //ti stands for
TextInput, as I am grabbing the user's input.

messageObj.width = ti_width.text;

messageObj.height = ti_height.text;

messageObj.weight = ti_weight.text;

message.body = messageObj;

producer.send( message );


private function messageHandler( event:MessageEvent ):void {

messageObj = Cargo( event.message.body ); //TYPE COERCION


The sending and receiving work fine, I'm having no issues
getting the messaging service to work. However, when I cast the
'event.message.body' as type 'Cargo' I get a type coercion error.

I cannot find help with this anywhere as all the examples use
Strings or other primitive types.

Any suggestions on how to get this to work?
2 Replies


Former Community Member

I have never done it like that, but using Blaze-DS and remove
objects you can try this?

private function messageHandler( event:MessageEvent ):void {

Cargo = vent.message.body as Cargo;




Level 1
thanks for the reply reis, but because there is a type
coercion error between the event.message.body of type Object and my
messageObj of type Cargo, if I try the "as" operator it just
returns null.

Any other ideas?