flex - create xml from object -


basically want create xmldesigner kind of thing in flex, using user can add/edit components , properties of view/dashboard. storing view structure in xml file. parsed file @ runtime , display view. how convert object (having properties , sub-objects) xml node (having attributes , elements) , add xml existing xml file. next time when parsed xml file i'll new component in view/dashboard.

for e.g, object structure of component in xml file :

<view id="productview" label="products"> <panel id="chartpanel" type="chart" charttype="pie2d" title="productwise sales"  x="215" y="80" width="425" height="240" showvalues="0" >     </panel>  </view> 

thanks in advance.

use xml (de)serialization library.

there many out there 1 thing have used , found stable flexxb. has got plethora of functions , swear it!

flexxb annotation based , easy use once hang of it.

here sample copied main web site.

        [xmlclass(alias="mock2replacement", idfield="id")]         public class mock3         {                 [xmlattribute]                 public var id : number = 3;                 [xmlattribute]                 public var attribute : boolean;                 [xmlelement(alias="objectversion")]                 public var version : number;                  public function mock3()                 {                         super();                 }         } 

you decorate each of variables annotation , tell kind of xml type be.

and create object

var target : mock3 = new mock3(); target.attribute = true; target.id = 5; target.version = 33; 

and do

flexxbengine.instance.serialize(target)

and result be

<mock2replacement attribute="true" id="5">   <objectversion>     33   </objectversion> </mock2replacement> 

and other awesome thing don't have have source of object decorate it.

there api handle that. using ap, de(serialized) solidcolor , lineargradient did not have source decorate it.

checkout general description , samples. , it's one swc install :)


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -