Does Flex 3 support threading? If so, are there any examples or links I could look at?
Somewhere, in Adobe, Flash Player does support multithreading... http://www.bytearray.org/?p=3007. It's just not publicly available yet.
Other than that, see Multithreading or green threading in actionscript? There are also a few articles on the internet about using Pixel Bender's multithreading for data processing.
As stated by Alex here:
Actionscript is single-threaded, if you spend lots of time doing heavy computation, the UI cannot be updated while you’re doing that computation so your application appears stuck or effects don’t run smoothly.
Similarly, there is no yielding or blocking in Actionscript either. If the next line of code is supposed to run, you cannot prevent the next line of code from running. That means that when you call Alert.show(), the next line of code following that runs right away.
In many other runtimes, the Alert window has to be closed before the next line of code continues. Threading may be a feature of Actionscript some day, but until then, you have to live with the fact that there is no such thing right now.
ActionScript 3 is single-threaded.
What you can do is cut the work in slices small enough that the responsiveness is not too affected. For example:
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
}
Flex 3 is based on ActionScript 3. ActionScript 3 does not provide support for multithreading ( you cannot write code aimed for multi-thread execution ). A compiled flex application runs on the Flash Player platform. Adobe Flash Player 11.4 and up added support for multithreading.
© 2022 - 2024 — McMap. All rights reserved.