UI组件的生命周期中的Flex生命周期、组件、UI、Flex

2023-09-08 12:12:35 作者:斯心裂肺的笑

在UI组件的生命周期中,我听到了验证和无效事件。请解释一下我,总之这些事件。什么是updateDisplayList()方法的生命周期做。请解释一下我的短,如果可能的。先感谢您。

In UI component life cycle, I heard validation and invalidation events. Please explain me about these events in short. What does updateDisplayList() method do in that life cycle. Please explain me in short if possible. Thank you in advance.

推荐答案

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():这是一个外卡的方法。您可以使用它来协调在一个地方的多个属性更改。你用它来做什么取决于你正在创建的组件和性能上。 的措施():这是用来设置理想的高度组件和宽度的基础上的孩子们。您设置measuredHeight和measuredWidth可以。 的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(),测量()和updateDisplayList() - 可在下一个render事件期间设置运行。为preP他们来说,使用适当的失效方法只是使它们无效:

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()力测量()来 重新运行。 在invalidateDisplayList()力量 updateDisplayList()中重新运行。 invalidateProperties() forces commitProperties() to rerun. invalidateSize() forces measure() to rerun. invalidateDisplayList() forces updateDisplayList() to rerun.

如何经常渲染事件触发取决于应用程序的帧速率。我觉得默认的Flex帧速率是每秒24帧,所以有一个render事件秒每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:

preinitialize 在初始化 childAdd将 updateComplete 的creationComplete

updateComplete将在每次渲染事件之后火,我相信。但是,另一些部件创建的一部分。

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

你应该阅读本 Flex文档

Spark组件生命周期增加了不同的挂钩,以适应这两个类的方法;一个类的业务逻辑,另一个用于剥皮。但是,它窗台扩展MX /光晕组件的生命周期。

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.