You should have parser/unmarshaller for the e4x/xml returned by the service and handle this situation in there. On the other hand what you are trying to achieive doesn't work like that out of the box I mean the conversion. Google for the ObjectTranslator utility for flex/as3 and use that to convert your object.
HTH, C ________________________________ From: Nick Middleweek <n...@middleweek.co.uk> To: flexcoders@yahoogroups.com Sent: Wed, January 6, 2010 4:22:09 PM Subject: [flexcoders] Problem Casting an Object to a known type Hello... We've just run into a problem... Has anyone else come across this before? We're making HTTP Service calls and we're getting back nested data. We have set the resultFormat="e4x" which we then parse into known Object types, such a IContactData, IInvoiceDetails. .. The Problem: With some service calls, the data returned has 4 or more levels of nested data. In these cases, Flex isn't giving us XML. It is just returning an untyped Object with the nested data. If the returned data has 3 levels or less of nested data then we get XML. We then thought, ok... The untyped Object returned by Flex does have all the properties required to Cast it to our typed Object, e.g. IContactData. .. But we are getting a "Coercion failed" message by the Compiler. Here's a basic example of the problem... var myPerson : Object = new Object(); myPerson.age = "25"; myPerson.sex = "dunno" myPerson.name = "Nick"; var myContact : ContactPerson = new ContactPerson( ); myContact = ContactPerson( myPerson) ; // Where ContactPerson is a typed Object with age, sex and name String properties. So has anyone managed to solve the 4 levels of nested data problem from an HTTP Service call? and :) Why can't we cast an untyped Object into a typed Object? :) Cheers guys... Nick