Flex3支持线程吗?如果是这样的话,有没有我可以看看的例子或链接?
发布于 2011-04-13 04:46:42
在Adobe的某个地方,Flash Player确实支持多线程...http://www.bytearray.org/?p=3007。只是还不能公开使用。
除此之外,在互联网上还有一个关于使用Pixel Bender的多线程进行数据处理的few articles。
发布于 2011-04-12 16:43:42
正如Alex here所说的
Actionscript是单线程的,如果你花了大量的时间做大量的计算,在你做计算的时候UI不能被更新,所以你的应用程序看起来卡住了或者效果不能流畅地运行。
类似地,在Actionscript中也没有让步或阻塞。如果假定运行下一行代码,则不能阻止运行下一行代码。这意味着当您调用Alert.show()时,紧跟其后的下一行代码将立即运行。
在许多其他运行时中,必须先关闭Alert窗口,然后才能继续执行下一行代码。有朝一日,线程可能会成为Actionscript的一个特性,但在那之前,你必须接受这样一个事实:目前还没有这种东西。
发布于 2011-04-12 16:58:30
ActionScript 3是单线程的。
您可以做的是将工作切成足够小的切片,以便响应性不会受到太大影响。例如:
private var _long_process_work_object:LongProcessWorkClass;
private var _long_process_timer:Timer;
private function startSomeLongAndIntensiveWork():void
{
_long_process_work_object = new LongProcessWorkClass();
_long_process_timer = new Timer(10);
_long_process_timer.addEventListener("timer", longProcessTimerHandler);
_long_process_timer.start();
}
private function longProcessTimerHandler(event:TimerEvent):void
{
_long_process_timer.stop();
// do the next slice of work:
// you'll want to calibrate how much work a slice contains to maximize
// performance while not affecting responsiveness excessively
_long_process_work_object.doSomeOfTheWork();
if (!_long_process_work_object.Done) {
// long process is not done, start timer again
_long_process_timer.start();
return;
}
// long process work is done, do whatever comes after
}https://stackoverflow.com/questions/5632469
复制相似问题