{"id":13744855,"url":"https://github.com/jcward/AS3-Worker-Compat","last_synced_at":"2025-05-09T04:30:57.879Z","repository":{"id":69029565,"uuid":"6678363","full_name":"jcward/AS3-Worker-Compat","owner":"jcward","description":"ActionScript Worker wrapper for compatibility with pre-and-post Flash Player 11.4","archived":false,"fork":false,"pushed_at":"2018-08-08T01:43:34.000Z","size":172,"stargazers_count":61,"open_issues_count":2,"forks_count":10,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-03T22:13:04.972Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"ActionScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcward.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2012-11-13T21:54:58.000Z","updated_at":"2021-01-13T21:41:34.000Z","dependencies_parsed_at":"2023-07-06T09:00:41.367Z","dependency_job_id":null,"html_url":"https://github.com/jcward/AS3-Worker-Compat","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcward%2FAS3-Worker-Compat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcward%2FAS3-Worker-Compat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcward%2FAS3-Worker-Compat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcward%2FAS3-Worker-Compat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcward","download_url":"https://codeload.github.com/jcward/AS3-Worker-Compat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253191765,"owners_count":21868803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T05:01:17.351Z","updated_at":"2025-05-09T04:30:57.596Z","avatar_url":"https://github.com/jcward.png","language":"ActionScript","readme":"AS3-Worker-Compat\n=================\n\nActionScript Worker wrapper for compatibility with all AS3 versions of the\nFlash Player (9 and later)\n\n\u003cb\u003eNEW:\u003c/b\u003e v0.2.1 includes AsyncScheduler and JPEGEncoder demo\n\nAbout\n=====\n\nWhat it does\n------------\n\nThe WorkerCompat wrapper simply uses dynamic-lookup to determine if the Worker\nAPI is available and supported.  This allows SWFs compiled with this code to be\nplayable on all version of the Flash Player, not just those with Worker support\n(11.4 and later).\n\nAs such, it also allows you to use an older compiler (Flash CS6, older version\nof Flash Builder or Flex, etc) to take advantage of Workers.\n\nFeatures\n========\n\n* v0.1\n  * WorkerCompat - backward-compatible Worker wrapper\n* v0.2\n  * XTSharedObject - dead-simple cross-thread data sharing\n* v0.2.1\n  * AsyncSchedule - asynchronous scheduler utility\n  * JPEGEncoder - Adobe lib with new pseudo-threaded encodeAsync() method\n  * JPEGEncoderTest - Demo showing the use of JPEGEncoder\n\nSee \u003ca href=\"https://github.com/jcward/AS3-Worker-Compat/edit/master/README.md#feature-details\"\u003eFeature Details\u003c/a\u003e below for more info.\n\nDemos\n=====\n\nThe demos showcase various aspects of the AS3-Worker-Compat library.  All will run\nin all versions of the Flash Player, and run via the use of Workers when supported,\nfalling back to pseudo-thread techniques when not.\n\nWorkerCompatTest\n----------------\n\nThe WorkerCompatTest demo shows a red \"radar-like\" graphic that is generated on-the-fly,\nwhile also running a CPU-burning while loop.  This demo SWF works in all Flash\nPlayer versions.\n\n\u003ca href=\"http://jcward.com/github/WorkerCompatTest_v0.2.1/WorkerCompatTest.swf\"\u003eTry it now in your browser\u003c/a\u003e.\n\nIf AS3 Workers are supported, the two tasks are run on separate threads\nand the graphic is a smooth fading radar.\n\nIf AS3 Workers are not supported, both tasks are run on the same thread\n(AS3 is inherently single-threaded) and the radar graphic is choppy -\nintentionally, for demonstrative purposes.  In a real-world application\nyou'd attempt to balance your background logic to leave the UI as smooth\nas possible even without Workers.\n\nHere's a screenshot of the demo in two browsers, one supporting Workers and\nthe other not.\n\n\u003cimg width=\"400\" src=\"http://jcward.com/github/WorkerCompatTest_v0.2.1/screenshot.png\"/\u003e\n\nJPEGEncoderTest\n---------------\n\nThe JPEGEncoderTest demo compares various JPEG encoding schemas:\n* synchronous native encoding (when supported, FP 11.3+)\n* synchronous encoding\n* asynchronous encoding utilizing the AsyncScheduler class\n  * Using AsyncScheduler.LOW, MEDIUM, and HIGH priorities\n\n\u003ca href=\"http://jcward.com/github/JPEGEncoderTest_v0.2.1/JPEGEncoderTest.swf\"\u003eTry it now in your browser\u003c/a\u003e.\n\nHere's a screenshot of the demo in two browsers, one supporting Workers and\nthe other not.  Noteice that with Worker support, asynchronous JPEG encoding\ndoes not reduce UI framerates.\n\n\u003cimg width=\"400\" src=\"http://jcward.com/github/JPEGEncoderTest_v0.2.1/screenshot.jpg\"/\u003e\n\nFeature Details\n===============\n\nWhat it doesn't do\n------------------\n\nThere's no magic - if your SWF is running in an environment without Worker\nsupport, there will still be UI blocking and pseudo-threading.  You'll need\nto write your application with this in mind to handle either case.  However,\nusing this library you'll get the peace of mind that:\n * your SWF will run on all Flash Players (and even compile to AIR for\n   mobile, which also doesn't support Workers), and\n * it'll simply take advantage of Worker threads when they're available.\n\nAlso, be aware when using dynamic/runtime class lookup, you don't get\ncompile-time type checking on those classes (Worker, WorkerDomain, etc).\nHowever, when building the demos, I found that I didn't use those classes\nat all but to instantiate my worker.  After that, it's all application logic.\n\nWhat's New in v0.2.1\n--------------------\n\nThis release brings a utility, AsyncScheduler, that makes converting synchronous, loop-based\nalgorithms (like JPEG encoding) into asynchronous, pseudo-threadable\nalgorithms easy.  Pseudo-threads are a must if you're going to support older,\nnon-threading Flash Players, but it's not a bad idea to write asynchronous\ncode even when utilizing Workers.  It allows a single background thread to\nservice many tasks simultaneously.\n\nConsequently, a new demo, JPEGEncoderTest, is new in v0.2.1 showcasing this\nnew functionality.  The standard JPEGEncoder library by Adobe was ported to\nasynchronous code using the AsyncScheduler.async helper function.\n\nIn WorkerCompatTest I also updated the code to better reflect that doGuiWork\nshould be responsible for setting up the stage (not necessarily the constructor,\nsince that's shared with the background worker).\n\nOh, I also changed the library namespace from com.lilcodemonkey to com.jcward -\nhope that didn't perturb anyone.  :)\n\nWhat's New in v0.2\n------------------\n\nThe major new feature in v0.2 is XTSharedObject.  If your first concern is a\nSWF that plays in all Flash Players, your second concern is how to easily get\nyour threads communicating together.\n\nXTSharedObject is a dead-simple Object that's shared between all threads,\nagain, coded to work the same whether the Flash Player supports Workers or\nnot.  There are usage requirements / gotchas at the top of the comments in\nXTSharedObject.as, and the WorkerCompatTest demo now uses it to pass a count\nvalue from the background worker to the foreground.\n\nWhile being incredibly easy to use, XTSharedObject is not the most performant\nway to share data between threads - if you're passing around large chunks of\ndata you should use shared ByteArrays (available in FP 11.5+) - maybe I'll\nadd such support later.\n\nWhat's New in v0.1\n------------------\n\nThe initial release, v0.1 introduced the WorkerCompat wrapper.  It contains\nthe dynamic class lookup calls which are the basis of detecting the Worker\nAPI regardless of Flash Player version.\n\nThis wrapper is an alternative to using static imports, which would cause a\nruntime-error in Flash Players earlier than 11.4, something like:\n\n\u003cpre\u003e\n An ActionScript error has occurred:\n  ReferenceError: Error #1065: Variable flash.system::Worker is not defined.\n\u003c/pre\u003e\n\nUsage / Conversion\n==================\n\nUsing WorkerCompat is as simple as changing these hard-coded worker references:\n\n\u003cpre\u003e\n  import flash.system.Worker;\n  import flash.system.WorkerDomain;\n\n  ...\n\n  if (Worker.isSupported \u0026\u0026 Worker.current.isPrimordial) {\n    var myWorker:Worker = WorkerDomain.current.createWorker(swfbytes);\n  }\n\u003c/pre\u003e\n\nTo this:\n\n\u003cpre\u003e\n  import com.jcward.WorkerCompat;\n\n  ...\n\n  if (WorkerCompat.workersSupported \u0026\u0026 WorkerCompat.Worker.current.isPrimordial) {\n    var myWorker:* = WorkerCompat.WorkerDomain.current.createWorker(swfbytes);\n  }\n\u003c/pre\u003e\n\nLicense (FreeBSD)\n=================\n\nCopyright (c) 2012, Jeff Ward\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met: \n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer. \n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution. \n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nThe views and conclusions contained in the software and documentation are those\nof the authors and should not be interpreted as representing official policies, \neither expressed or implied, of the FreeBSD Project.\n","funding_links":[],"categories":["Unsorted"],"sub_categories":["Other API"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcward%2FAS3-Worker-Compat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcward%2FAS3-Worker-Compat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcward%2FAS3-Worker-Compat/lists"}