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
ERROR HERE!!!!
}
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?