ActionScript:将闭包推入事件堆栈? [英] ActionScript: pushing a closure onto the event stack?

查看:20
本文介绍了ActionScript:将闭包推入事件堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,我想将闭包推送到 ActionScript 的事件堆栈,以便在当前事件处理程序之后执行.现在我使用 setTimeout(closure, 0).有没有更直接的方法?

On occasion, I have wanted to push a closure onto ActionScript's event stack so that it will be executed after the current event handler. Right now I use setTimeout(closure, 0). Is there a more direct way of doing this?

推荐答案

setTimeout(closure, 0) 正在创建一个新的事件堆栈.如果此解决方案不适合您,我不明白您的目标.你要实现的目标是什么?

setTimeout(closure, 0) is creating a new event stack. I don't understand your objective if this solution isn't working for you. What is the goal you're trying to accomplish?

Flex 有 ENTER_FRAME 事件、Timer、callLater、setTimeout、setInterval,所有这些都可以延迟调用并创建新的执行堆栈.

Flex has ENTER_FRAME events, Timer, callLater, setTimeout, setInterval, all which delay calls and create new execution stacks.

您是否尝试将代码注入当前堆栈?如果是这样,您可能需要查看以下内容:http://en.wikipedia.org/wiki/Active_object.这个想法是你将函数(闭包)推入一个数组,当前一个运行完成时,活动对象控制器从列表中拉出下一个.这是最简单的情况.您可以编写一个更复杂的程序,它具有高、中、低等优先级堆栈,并带有您自己的日程管理系统.(例如,等待时间过长后获得晋升).

Are you trying to inject code into the current stack? If so, you might need to look at something like this: http://en.wikipedia.org/wiki/Active_object. The idea being that you push functions (closures) into an array, and the active object controller pulls the next one off the list when the previous one has run to completion. That's the simplest case. You can write a more complicated one that will have priority stacks like high, medium, low, with your own schedule management system. (e.g., low get promoted after waiting too long).

但是嘿!细节决定成败.目标是什么?

But hey! The devil is in the details. What's the goal?

这篇关于ActionScript:将闭包推入事件堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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