You could try using describeType (I think that only returns public
though).

Changed what is below on the fly from something similar I had that only
serialized accessors, so there might be syntax and other errors in


     public static function toXml(obj:Object):XML {
       var
oDescrCache:DescribeTypeCacheRecord=DescribeTypeCache.describeType(obj);
       var oDescr:XML=oDescrCache.typeDescription;
       var clazzName:[EMAIL PROTECTED];
       var props:XMLList=oDescr..accessor;
       var prop:XML;
       var propName:String;
       var propType:String;
       var childXml:XML;

       var oXml:XML=<{clazzName}/>;
       for each (prop in props) {
         [EMAIL PROTECTED];
         [EMAIL PROTECTED];
         if(propType=="String" || propType=="int" || propType=="Number"
|| propType=="Date") {
           oXml['@'+ propName]=obj[propName];
         } else if (propType=="mx.collections::ArrayCollection") {
           for each (var childProp:Object in obj[propName] ) {
             childXml=XMLSerializer.toXml(childProp);
             oXml.appendChild(childXml);
           }
         } else {
           childXml=XMLSerializer.toXml(obj[propName]);
           oXml.appendChild(childXml);
         }

       }
       return oXml;
     }

Perhaps it helps you getting started


Peter

--- In [email protected], "tungchau81" <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I need to convert an AS3 class into XML based on all the
public/private
> properties that the AS3 class has. However, I have not been able to
> find a way or any API that allow me traverse through all properties
> that a class has. This should be a generic way that can be applied to
> any AS3 class.
>
> I did look at the XMLTools.as file written by Michael J. Prichard.
> However, it seems to work with AS2 only.
>
> Any advice is greatly appreciated.
>
> Regards,
> Tung Chau
>

Reply via email to