lundi 21 novembre 2016

How to get object attribute with weird name

I have a situation where the name of an attribute is xml namespace::element (e.g. It is weird situation because I can read it, but I can't access it. Here is an example:

var name: String = "";
var obj: Object = createAttributes(name);

// Now we have obj:{ "" : [an array] }

for (var attr : Object in obj[name]){
    // do something

This is just a simplification of the real thing. It seems like I can't read it neither with, nor obj[name], nor obj['"' + name + '"'].

I have even tried something like this (with different types for elem):

for (var elem: Object in obj) { // I tried Object, Array and * here
    for (var c: Object in elem)
        // do something with c

Why is this happening and how to overcome this issue? Since it is interesting problem, please don't consider changing the way I create obj. AS3 allows creation of such attribute and I am wandering how we are suppose to use it.

Aucun commentaire:

Enregistrer un commentaire