Archive for July, 2008

Targeting XMLSchema subtypes for anonymous ActionScript Objects

When encoding ActionScript objects to XML using a schema, such as when using a SOAP based WebService, it is not uncommon to provide a subtype (say, an Employee class) to an API that merely specifies a base type (say, a Person class). An issue is that the encoder does not know the subtype that your value is targeting so you must provide a hint. For the decoding XML to ActionScript case, an xsi:type attribute provides the decoder with such a hint… so an equivalent is needed in ActionScript for the encoding XML case.

For strongly typed objects, you can implement the mx.rpc.xml.IXMLSchemaInstance interface to provide a QName for the xsiType property to target the subclass to be used during encoding. See:

For anonymous ActionScript Objects, however, you may not know that you can wrap your object in an mx.utils.ObjectProxy instance and set its type property with a QName to achieve the same effect. See:

Continue reading…