English 中文(简体)
AS3 组合框查找 xml
原标题:AS3 combo box referencing xml

我对动作描述非常新, 我有一个场景。 我有一个组合框“ 元素 Picker ”, 我有一个工程, 从 XML 文件装入图像, XML 文件设置为

<elements>
<head>
   <imgpath>/img/x.png</imgpath>
</head>
<head>...</head>
<head>...</head>

<eyes>...</eyes>
<eyes>...</eyes>
<eyes>...</eyes>
</elements>

因此,在我的组合框中,我有一个选项,比如“头”、“眼”等等。我想要的是基于组合框中的数据,以改变哪些 xml 元素被装入我持有图像路径的阵列。

我尝试过类似

var comboSelection:String = elementPicker.selectedItem.label;

然后,当我环绕以将路径放入数组时:

elementPathList.push(theXMLData.comboSelection.imgpath[ b ]);

但此功能不起作用, 输出显示: TypeError: 错误# 1009: 无法访问无效对象引用的属性或方法 。

知道该怎么做吗?

问题回答

我不知道我是否完全理解这个问题,但类型错误告诉你,组合选择(从字面上看,不是数值,而是该词)并不存在作为您的 XMLData 对象属性的属性,而基于您所张贴的内容,该对象的属性是真实的。

como 选择不是“看到”您创建的本地变量或它的价值,而是 XMLData 对象的属性,因此它不是类型错误。

您想要做的似乎是在列表中找到带有相应属性的项目, 您可以使用 E4X 来实现这一目标, 并用 e4x 来查找细节。 (@ nodeName=comboSection) head. imgpath 。

然而,我认为一个更好的方法就是将组合框中含有有标签属性并直接与对象有实际源路径的数值对象填充成一个数值对象。 这样您就可以使用元素Picker.sselective. imgPath, 而不是试图事后在 XML 中查找它。 这个解决方案会降低代码的混乱度和速度。 如果您无法自己这样做, 您可以在您的组合框和您如何重新装入 XML 上发布更多的代码, 我可以帮助您修改该代码, 以实现我所解释的目标 。

如果代码相当大,你可以把它贴到糊盘上,然后在您原来的文章中掉一个链接。

既然你让我安心了,我拿了点钱......这是两个结果:

http://www.shaunhusain.com/FlashAvaEditor/" rel="nofollow" >http://www.shaunhusain.com/FlashAvaEditor/

http://www.shaunhusain.com/FlexAvaEditor/

右右单击 弹性 1 来源, 我在这里包装 FLA 的文件

http://www.shaunhusain.com/FlashAvaEditor/FlashAvaEditor.zip" rel=“nofollow'>http://www.shaunhusain.com/FlashAvaEditor/FlashAvaEditor.zip

让我知道你对这个方法的看法, 或者如果我错过了标记。





相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签