flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harbs <harbs.li...@gmail.com>
Subject FlexJS XML problem
Date Mon, 28 Aug 2017 09:07:12 GMT
Given the following XML in Flash:
var xml:XML = <root/>;
xml.bar.foo.baz = "baz";

You get an XML structure like so:

In JS, this compiles to the following:

  var /** @type {XML} */ xml = new XML( '<root/>');
  xml.child('bar').child('foo').setChild('baz', "baz");

.child() returns an empty XMLList
.setChild() tries to add a child to that empty list and does not create the structure.

I’m not sure how to best solve this problem.

One idea would be to add a new function called getChild() which would return an existing element
if it exists and create a new one if not. Then we could have the compiler rewrite the output

  xml.getChild('bar').getChild('foo').setChild('baz', "baz");

I’d prefer to try and figure out how to have setChild walk up the reference tree and create
the correct elements automatically. I’m having trouble figuring out how to do that though.

View raw message