Flex中SetProperty和RemoveChild的区别
我是 Flex 新手。最近,我正在学习Flex中的“状态”概念。
当状态改变时,我们可以为新状态定义新属性,覆盖基本状态的属性。
但是,我有一个疑问。
在Flex中使用setProperty()和removeChild()有什么区别?
看下面的例子。
假设应用程序容器内有2个Vbox。当状态因某些事件而改变时,我只需要 appln 容器中的 1 个 VBox。
(a) 我应该为宽度和宽度的特定 VBox 设置 setProperty 高度为 0 ?或
(b) 我应该删除 通过使用来自新状态的 VBox 移除Child() 属性?
I am new to Flex. Recently, I am learning about 'state' concept in Flex.
When state is changed, we can define the new properties for the new state overidding the properties of the base state.
But, I had a doubt.
What is the difference between using setProperty() and removeChild() in Flex ?
Take the following case.
Suppose there are 2 Vbox inside the application container. When the state is changed by some event, I need only 1 VBox in the appln container.
(a) Should I set setProperty for that particular VBox of width and
height to 0 ? or
(b) Should I remove the
VBox from the new state by using
removeChild() property ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
他们是不同的。
SetProperty 意味着更改实例的某些属性,您可以设置您可以在上下文中访问的任何属性。如果您将来需要重新使用 VBox(我认为这是您的情况),您应该使用此功能。通常,不要将 width 和 height 设置为 0(某些组件具有 minimumWidth 和 minimumHeight ,这可能会破坏您的逻辑)。相反,请将其 visible 设置为 false,并将 includeInLayout 设置为 false。
仅当您不再需要该 VBox 时才使用removeChild。否则,当您需要addChild将其添加到布局中时,您必须重新排列组件子级的顺序。
They are different.
SetProperty means changing some properties of the instance, you can set any property that you can access in the context. In case you need to re-use the VBox in future (i think this is your case), you should utilize this function. Normally, don't set width and height to 0 (some components has minimumWidth and minimumHeight that can break your logic). Instead, set its visible to false and includeInLayout to false too.
You only use removeChild when you no longer need that VBox. Otherwise, when you need to addChild it into your layout, you have to rearrange the order of the component's children.