Flex 中是否有一个事件会在 mx:state 标记中的所有操作完成时触发?

发布于 2024-09-16 05:08:34 字数 433 浏览 9 评论 0原文

让我们看下一个例子:

<mx:State name="sayHello">
            <mx:SetProperty name="preText" target="{this}" value="Hello"><mx:SetProperty>
</mx:State>

我能以某种方式知道 preText 属性何时设置为 hello 吗?

已经尝试过: 状态->激活 状态->进入状态 state->exitState

UIComponent->currentStateChange

在上述所有情况下,pretext 属性为 null,无论如何,稍后它会获得所需的值(我用计时器进行了测试)

任何帮助都会很棒! 谢谢!

Let's take the next example:

<mx:State name="sayHello">
            <mx:SetProperty name="preText" target="{this}" value="Hello"><mx:SetProperty>
</mx:State>

Can I somehow know when preText property has been set to hello?

Already tried with:
state->activate
state->enterState
state->exitState

and

UIComponent->currentStateChange

In all the cases above,pretext property is null, how ever somehow, later on it gets the desired value (I tested with a timer)

Any help would be great!
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

够钟 2024-09-23 05:08:34

很难说。 Flex 框架实现的大多数属性都会调度 propertyChangedEvent。因此,在这种情况下,您可以监听相关组件上的 preTextChanged 事件,让您知道属性已更改。

如果这是您自己实现的属性,只需让属性设置方法分派事件,如下所示:

dispatchEvent(new Event('preTextChanged'));

添加监听器,如下所示:

this.addEventListener('preTextChanged',onpreTextChanged);

如果不定义事件,您将无法监听 MXML 中的属性更改事件事件的元数据;大多数组件都懒得为 propertyChanged 事件定义元数据。

改变状态的行为可能需要时间。由于 Flex/Flash Player 的异步特性,如下所示:

currentState = newState
trace(preText);

跟踪值很可能尚未设置,因为状态更改处理尚未发生。您也许可以收听 currentStateChange< /a> 不过,事件。当调度时,您的属性都应该被修改。

It is tough to say. Most properties implemented by the Flex Framework dispatch a propertyChangedEvent. So, in this case you could listen to preTextChanged event on the component in question to let you know that the property changed.

If this is a property you implemented yourself, just make the properties set method dispatch the event, like this:

dispatchEvent(new Event('preTextChanged'));

Add the listener like this:

this.addEventListener('preTextChanged',onpreTextChanged);

You won't be able to listen to the property change event in MXML if you don't define event metadata for the event; and most components do not bother to define metadata for the propertyChanged event.

The act of changing a state can take time. Due to the asynchronous nature of Flex/Flash Player something like this:

currentState = newState
trace(preText);

The trace value will most likely not be set yet because the state change processing did not occur yet. You may be able to listen to the currentStateChange event, thoug. When that dispatches your properties should all be modified.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文