使用actionscript(如javascript)选择MXML 兄弟姐妹?
我正在尝试获取 mxml 标签的同级,类似于在 javascript 中选择同级的方式。这在 Actionscript 中可能吗?
例如,当我单击 ID 为 textarea1
的 TextArea
时,我需要它告诉我同级的 id 为 rect1
,这样我就可以对其进行进一步处理。
<s:Group>
<s:TextArea id="textarea1" click="getSibling(event)" />
<s:Rect id="rect1" />
</s:Group>
I'm trying to get the sibling of an mxml tag similar to the way siblings are selected in javascript. Is this possible in Actionscript?
For example, when I click the TextArea
with id textarea1
, I need it to tell me that the sibling has an id of rect1
so I can do further processing to it.
<s:Group>
<s:TextArea id="textarea1" click="getSibling(event)" />
<s:Rect id="rect1" />
</s:Group>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设 Group、TextArea 和 Rect 是 UIComponent,我认为这应该可行:
Assuming Group, TextArea and Rect are UIComponents, I think this should work:
我最初的想法是访问父级,然后检索其中的子级列表。
这是关于Javascript此处进行讨论的。
希望这有帮助。
尼克
nickgs.com
My initial thought here is to access the parent and then retrieve a list of children within it.
This was discussed with respect to Javascript here.
Hope this helps.
Nick
nickgs.com
据我所知,没有办法做到这一点。但是,textarea1 和 rect1 都是该组的子级。如果您给该组一个 ID,您应该能够循环所有子项以找到 TextArea 的所有同级。
在 Flex 3 中,您可以使用 for 循环、numChildren 和 getChildAt。我怀疑 Flex 4 中也会有类似的情况。
As far as I know there is no way to do this. However, both textarea1 and rect1 are children of the Group. If you give the group an ID you should be able to loop over all the children to find all the siblings of the TextArea.
In Flex 3, you'd use a for loop, numChildren, and getChildAt. I suspect in Flex 4 it would be similar.