Did you try it? It should have at least compiled. What error did you get?
In FlexJS, MXML is not converted to code, but the net result should be equivalent to: var comp:Object = new Rect(); this[“myRect”] = comp; comp.width = 300; comp.height = 300; comp.x = 10; comp.y = 10; var comp2:Object = new SolidColor(); comp2.color = ‘#ff0000’; comp.fill = comp2; someParent.addElement(comp); Note that: 1) I’m not sure “#ff0000” will be converted to 0xFF0000. It might, but if not, you can ask the ValuesManager to convert it, which would someday allow you to handle “red”, “green”, etc. 2) The color is applied to SolidColor before it is assigned as the fill. 3) There is probably no way to get the compiler to generate the call to drawRect. Based on what interfaces you implement, you could get notified during the addElement call or you could get a setDocument call and draw then. You could also require that these elements get wrapped by some other class that is a IUIBase and sort of like Canvas, then the Rect and other tags become a data structure assigned to a default property in that “Canvas”. Then when the Canvas is added or resized it would draw based on its data. -Alex On 10/15/14, 1:05 AM, "OmPrakash Muppirala" <bigosma...@gmail.com> wrote: >I am quite satisfied with the way the drawing APIs are shaping up. Before >I continue adding more APIs, I would like to make them work from MXML so >that I can start importing some real graphics (exported from Adobe >Illustrator) and see it render in Flash and HTML5. > >Here is a basic requirement: > >When I write: > > <svg:Rect id="myRect" width="300" height="300" x="10" y="10"> > <svg:fill> > <basic:SolidColor color="#FF0000" /> > </svg:fill> > </svg:Rect> > >It must get converted into this code: > >var myRect:Rect = new Rect(); >myRect.fill = new SolidColor(); >myRect.fill.color = 0xFF0000; >myRect.drawRect(10,10,300,300); > >How would I go about doing this? > >I am guessing I need to make changes to my API to make it work from MXML, >obviously which I am willing to do. > >Thanks, >Om