【问题标题】:Is there a way to store XML.appendChild function in a variable?有没有办法将 XML.appendChild 函数存储在变量中?
【发布时间】:2014-04-18 14:26:00
【问题描述】:

我想使用类似的东西:

var addFunction:Function = needParentNode ? parentNode.appendChild: resultArray.push;

for each(var element:* in elements){
    addFunction(element);
}

但是parentNodeXML,所以parentNode.appendChild 返回一个XMLList 因为E4X 语法。 parentNode['appendChild'] 是一样的。 我知道我可以得到一个包装器

function(item:*){parentNode.appendChild(item)}

但是有没有办法让这个功能不那么复杂?

【问题讨论】:

  • “返回XMLList”是什么意思?根据文档appendChild 返回XMLhelp.adobe.com/en_US/FlashPlatform/reference/actionscript/3/…
  • OP 的意思是 parentNode.appendChild 不带括号将其表示为函数调用将解析与声明相同的声明 parentNode['appendChild'] 将返回一个名为“appendChild”的任何子级的 XMLList "。

标签: actionscript-3 apache-flex e4x


【解决方案1】:

试试这个,

parentNode.AS3::appendChild

指定命名空间可能会有所帮助。

【讨论】:

  • 谢谢,真的很管用!很高兴看到它,因为我预计这个问题无法解决。
  • 我很高兴你很高兴:')
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-17
  • 2014-06-11
  • 1970-01-01
  • 2022-01-23
  • 2020-03-17
  • 1970-01-01
相关资源
最近更新 更多