
Код:
XMLC.prototype.__resolve = function (p) {
if (!isNaN(p)) {
return this._childNodes[p];
} else if (p.charAt(0) == ATTRIBUTE_ACCESSOR) {
var attr:String = p.slice(1, p.length);
if(attr.length){
if (this._attributes[attr] != undefined) {
return this._attributes[attr];
} else {
this._attributes[attr] = '';
return this._attributes[attr];
}
} else {
return this._attributes;
}
} else if(p instanceof String) {
for (var i:Number = 0; i < this.childNodes.length; i++) {
if (this._childNodes[i].nodeName == p) {
return this._childNodes[i];
}
}
this._childNodes.push(new XMLC(p));
return this._childNodes[this._childNodes.length - 1];
}
return undefined;
}
Ну вот кусок кода, чтобы было понятнее зачем мне это нужно =) В двух словах - имитация ХМЛ из АС3 в АС2 =) Т.е. хочется сделать что-то на подобие хml.@attribute = 'abc'.
T.e. если делать так: хml.@['attributeName'] = 'abc'; то работает, но это не красиво =)