Does Flex 3 support threading?
Asked Answered
T

4

6

Does Flex 3 support threading? If so, are there any examples or links I could look at?

Tisbe answered 12/4, 2011 at 8:36 Comment(0)
G
6

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.

Gombach answered 12/4, 2011 at 20:46 Comment(0)
M
4

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.

Moschatel answered 12/4, 2011 at 8:43 Comment(0)
C
4

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
}
Cavorelievo answered 12/4, 2011 at 8:58 Comment(0)
E
0

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.

Ellary answered 7/10, 2015 at 19:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.