Flex 中的 UI 组件生命周期 [英] UI Component life cycle in Flex

查看:53
本文介绍了Flex 中的 UI 组件生命周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 UI 组件生命周期中,我听说过验证和失效事件.

In UI component life cycle, I heard validation and invalidation events.

请简要解释一下这些事件.

Please explain me about these events in short.

updateDisplayList() 方法在那个生命周期中做了什么.

What does updateDisplayList() method do in that life cycle.

如果可能,请简短地解释一下.

Please explain me in short if possible.

先谢谢你.

推荐答案

Flex 组件生命周期是 Flex 用来设置组件的一组方法和事件.在扩展 UIComponent 类的我们自己的组件中,我们可以侦听这些事件或覆盖这些方法来执行特定于我们组件的操作.

The Flex Component LifeCycle is a set of methods and events that Flex uses to set up components. In our own components, that extend the UIComponent class, we can listen to these events or override these methods to do stuff that is specific to our component.

我要补充一点,updateDisplayList() 是一个方法,而不是一个事件,以防万一它们有任何混淆.

I'll add that updateDisplayList() is a method, not an event, just in case their is any confusion.

这些是主要的可覆盖方法:

These are the main overridable methods:

  • createChildren():用于创建组件的子级.
  • commitProperties():这是一个通配符方法.您可以使用它在一个地方协调多个属性更改.它的用途取决于您创建的组件和属性.
  • measure():用于根据子项设置组件的理想"高度和宽度.您设置了测量高度和测量宽度.
  • updateDisplayList():这用于执行任何与显示相关的操作,最常见的是组件子组件的位置和大小.
  • createChildren(): This is used to create a component's children.
  • commitProperties(): This is a wild card method. You use it to coordinate multiple property changes in a single place. What you use it for depends on the component you're creating and the properties.
  • measure(): This is used to set the "ideal" height and width of the component, based on the children. You set the measuredHeight and measuredWidth.
  • updateDisplayList(): This is used to do anything display related, most commonly position and size the component's children.

所有这些方法都将在初始组件创建期间运行.但是,其中的三个方法——commitProperties()、measure() 和 updateDisplayList()——可以设置为在下一个呈现事件期间运行.要准备运行它们,只需使用适当的失效方法使它们失效:

All of these methods will running during the initial component creation. However, three of these methods--commitProperties(), measure(), and updateDisplayList()--can be set up to run during the next render event. To prep them for run, just invalidate them using the appropriate invalidation method:

  • invalidateProperties() 强制commitProperties() 重新运行.
  • invalidateSize() 强制 measure()重新运行.
  • invalidateDisplayList() 强制updateDisplayList() 重新运行.

渲染事件的触发频率取决于您的应用程序的帧速率.我认为默认的 Flex 帧速率是每秒 24 帧,因此每 1/24 秒有一个渲染事件.

How often a render events fires depends on your application's frame rate. I think the default Flex frame rate is 24 frames per second, so there is one render event every 1/24th of a second.

我将组件生命周期定义为方法和事件的集合.所以,这些是事件,按照它们触发的顺序:

I defined the component lifecycle as being a collection of methods and events. So, these are the events, in the order they fire:

  • 预初始化
  • 初始化
  • childAdd
  • 更新完成
  • 创建完成

updateComplete 将在每个渲染器事件后触发,我相信.但其他是组件创建的一部分.

updateComplete will fire after every renderer event, I believe. But the others are part of the component creation.

您应该阅读有关此内容的 Flex 文档

Spark 组件生命周期向适应两类方法;一类用于业务逻辑,一类用于蒙皮.但是,它仍然扩展了 MX/Halo 组件生命周期.

The Spark Component Lifecycle adds different hooks to accommodate the two class approach; with one class for business logic and one for skinning. But, it sill extends the MX/Halo component Lifecycle.

这篇关于Flex 中的 UI 组件生命周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆