<p>I was wondering if there are any code or class libraries out there on how to implement multithreading or "green threading" in ActionScript.</p>

<p>As you've might seen, Scott Peterson is developing some kind of toolset, but I haven't found any more info on this other than his performance on the Adobe MAX Chicago event.</p>

<p>Regards Niclas</p>

[{'answer_id': 70335, 'author': 'anirudhsasikumar', 'author_id': 11433, 'author_profile': 'https://Stackoverflow.com/users/11433', 'pm_score': 1, 'selected': False, 'text': '<p>There\'s no built-in way to do green threading in ActionScript. You have to write code to handle it.</p>\n\n<p>Make a function that performs one iteration of whatever operation you want to do. It should return true or false depending on if its job is done or not. Now, you have to compute the time interval left to the next screen update on the ENTER_FRAME event. This can be done using flash.utils.getTimer.</p>\n\n<pre><code>start = getTimer();\n//thread is a ui component added to system manager that is redrawn each frame\nvar fr:Number = Math.floor(1000 / thread.systemManager.stage.frameRate);\ndue = start + fr;\n</code></pre>\n\n<p>Keep on executing your function while checking the function\'s return value each time and checking if due time has been crossed by comparing getTimer() with due.</p>\n\n<p>This has been implemented into a usable class by Alex Harui in the blog entry - <a href="http://blogs.adobe.com/aharui/2008/01/threads_in_actionscript_3.html" rel="nofollow noreferrer" title="Threads in ActionScript">Threads in ActionScript</a></p>\n'}, {'answer_id': 78440, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': -1, 'selected': False, 'text': '<p>I\'m a graphics guy, not a programmer, so I\'m not sure this will help you. BUT!</p>\n\n<p>I make all my GUIs multi-frame "movies" and write each gui thread on a different frame. Make sure that you only have 1-3 threads, and set your FPS to 30 or 60.</p>\n\n<p>This is useful for little projects because its bug-resistant and implementation is done for you.</p>\n'}, {'answer_id': 434205, 'author': 'RickDT', 'author_id': 5421, 'author_profile': 'https://Stackoverflow.com/users/5421', 'pm_score': 2, 'selected': False, 'text': '<p>Here\'s a Green Threading lib from Drew Cummins:</p>\n\n<p><a href="http://blog.generalrelativity.org/?p=29" rel="nofollow noreferrer">http://blog.generalrelativity.org/?p=29</a></p>\n'}, {'answer_id': 805012, 'author': 'Assembler', 'author_id': 5503, 'author_profile': 'https://Stackoverflow.com/users/5503', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://www.quasimondo.com/archives/000071.php" rel="nofollow noreferrer">It\'s an old article</a>, but <a href="http://www.quasimondo.com/" rel="nofollow noreferrer" title="quasimondo">quasimondo</a>\'s method of launching multiple swfs and then sharing the data over a LocalConnection may also be of interest.  They were saying that the back and forth of using the LocalConnection may eat up a few cycles, but if the iterations being processed are complex enough it shouldn\'t be too much of a problem.</p>\n'}]
['https://Stackoverflow.com/questions/70232', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']