在 Flex 中使用可绑定 getter 时获取目标
我有以下文件: 模型.as clint.mxml
在 clint.mxml 我有以下行:
<s:Group id='clint1' x="model.locationX">
...
在 model.as 我有一个 getter:
[bindable(event="locationXChanged"))
function get locationX () : int {
return ...
}
我的问题是我需要在 getter locationX 中知道获取 id 的对象的 id 是 clint1 ( mxml 中的对象 ID)。
I have the following files:
model.as
clint.mxml
in clint.mxml I have the following line:
<s:Group id='clint1' x="model.locationX">
...
in the model.as I have a getter:
[bindable(event="locationXChanged"))
function get locationX () : int {
return ...
}
My problem is that I need to know within the getter locationX that the id of the object that is getting the id is clint1 (The object id in the mxml).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
getter 的结果不应取决于调用它的对象。我想你的吸气剂不应该是吸气剂,也许应该采用 clintId 作为参数。
The result of a getter should not depend on which object it is called from. I guess your getter should not be a getter and should maybe take a clintId as argument.
您可以使用
this
来引用当前组件。您可以使用“this.id
”来查找组件的名称。有关 id 属性的详细信息。然而,我从你的问题和问题的标题中得到了混合的信号。您是否要求绑定源内的绑定目标的 id?实现这一点会增加对组件的依赖性,从而损害它们的重用能力。
You can use
this
to refer to the current component. You can use 'this.id
' to find out the component's name. More info on id property.However, I'm getting mixed signals from your question and the question's title. Are you asking for the id of the binding target inside the binding source? Implementing that would add dependencies to your components thus harming their ability for reuse.