{"id":27111955,"url":"https://github.com/johnbrandle/as3-js","last_synced_at":"2025-04-07T01:25:34.180Z","repository":{"id":40614205,"uuid":"180837913","full_name":"johnbrandle/as3-js","owner":"johnbrandle","description":"ActionScript 3 to JavaScript compiler","archived":false,"fork":false,"pushed_at":"2023-03-14T19:16:17.000Z","size":45220,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T14:01:49.104Z","etag":null,"topics":["actionscript","actionscript3","as3","compiler","flash","javascript","nodejs","npm","swc","swf","transcompiler"],"latest_commit_sha":null,"homepage":"https://johnbrandle.github.io/as3-js/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnbrandle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-11T16:53:11.000Z","updated_at":"2025-03-17T08:02:18.000Z","dependencies_parsed_at":"2022-08-26T13:10:19.587Z","dependency_job_id":null,"html_url":"https://github.com/johnbrandle/as3-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbrandle%2Fas3-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbrandle%2Fas3-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbrandle%2Fas3-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbrandle%2Fas3-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnbrandle","download_url":"https://codeload.github.com/johnbrandle/as3-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247575673,"owners_count":20960816,"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":["actionscript","actionscript3","as3","compiler","flash","javascript","nodejs","npm","swc","swf","transcompiler"],"created_at":"2025-04-07T01:25:33.651Z","updated_at":"2025-04-07T01:25:34.168Z","avatar_url":"https://github.com/johnbrandle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# as3-js\n\n[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://travis-ci.org/joemccann/dillinger) [![Dependency Status](https://david-dm.org/dwyl/esta.svg)](https://david-dm.org/dwyl/esta) [![Known Vulnerabilities](https://snyk.io/test/github/dwyl/hapi-auth-jwt2/badge.svg?targetFile=package.json)](https://snyk.io/test/github/dwyl/hapi-auth-jwt2?targetFile=package.json) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)\n\nas3-js is an ActionScript 3 to JavaScript compiler, with both browser and Node.js support.\n\n  - IE11, Edge, Chrome, Firefox, Safari (iOS9+)\n  - Node.js 10.15.3+\n\n# Supports:\n\n  - Run-time compilation\n  - [SWC files][swc]\n  - flash.* API\n  - XML, XMLList, Proxy, Dictionary, and E4X* (*see docs*)\n  - Almost all AS3 language features\n\n# Does not support:\n  - [with][with]\n  - package-level static initializers (class-level supported)\n  - lazy initialization of non-static property values:\n```actionscript3\nprivate var foo1:* = foo2; //undefined, not 5\nprivate var foo2:* = 5;\n```\n  - weak references\n  - named closures in conditionals:\n ```actionscript3\nif (false) function foo() {} //compilation error\n```\n  - non-unique custom namespace identifiers:\n ```actionscript3\npublic var myNamespace;\nnamespace myNamespace = 'foo'; //conflict\n```\n\n# Install:\n```bash\nnpm install @johnbrandle/as3-js\n```\n\n# Basic Usage:\n\n##### Browser\n```actionscript3\n/* c:/projects/hello/source/com/foo/Hello.as */\n\npackage com.foo\n{\n    public class Hello\n    {\n        public function say():String\n        {\n            return document.getElementById('hello_world').innerHTML;\n        }\n    }\n}\n```\n\n```javascript\n/* node compilation script */\n\nconst as3_js = require('@johnbrandle/as3-js');\n\nlet props =\n{\n\tsrcDir:'c:/projects/hello/source', //where *.as files are located\n\tmainFile:'/com/foo/Hello.as', //main class file relative location to srcDir\n\texpose:'hello', //what variable name to set main class instance to\n\tplatform:'browser' //environment where compiled js will run, options: \"node|browser|player\"\n}\n\nlet result = as3_js.compile(props);\n\nfs.writeFileSync('c:/projects/hello/build/js/hello.js', result.js, 'utf8');\n```\n\n```html\n\u003c!-- c:/projects/hello/build/index.html --\u003e\n\n\u003cdiv id=\"hello_world\"\u003ehello world\u003c/div\u003e\n\n\u003cscript src=\"js/hello.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    trace(hello.say()); //outputs hello world to console\n\u003c/script\u003e  \n```\n##### Browser (Runtime)\n```html\n\u003cscript src=\"node_modules/@johnbrandle/as3-js/_excluded/_generated/as3_js.browser.3.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    let request = new XMLHttpRequest();\n    request.open('GET', 'node_modules/@johnbrandle/as3-js/_excluded/_generated/builtin.browser.swc', false); //recommend changing this to asynch\n    request.send(null);\n\n    let constructs = as3_js.getSwcUtil().parseSWCString(request.responseText); //recommend caching result\n\n    let script = 'trace(\"hello world\");';\n    let code = 'package { public function actionScript(scope:Object, args:*):* { return (function() {' + script + '\\n\\n}).apply(scope, args || []); } }';  \n\n    let construct = as3_js.getAnalyzer().analyze(as3_js.getParser().parse(as3_js.getLexer().lex(code).tokens), constructs, 3, true, true);  \n    let result = as3_js.getTranslator().translate(construct, constructs, true, false, false);  \n\n    let value = '(function() { var $window = this; var window = $window.parent || $window; var document = window.document; var $es4 = window.$es4 || (window.$es4 = {}); var _ = window._; var $ = window.$;\\n\\n' + result + '\\n\\n})();';  \n\n    eval(value); //outputs hello world to console\n\u003c/script\u003e\n```\n##### Node\n\n\n```actionscript3\n/* c:/projects/hello/source/com/foo/Hello.as */\n\npackage com.foo\n{\n    public class Hello\n    {\n        public function say():String\n        {\n            const os = require('os');\n\n            return os.platform() == 'aix' ? global.Buffer.from('hello world').toString() : 'hello world';\n        }\n    }\n}\n```\n\n```javascript\n/* node compilation script */\n\nconst as3_js = require('@johnbrandle/as3-js');\n\nlet props =\n{\n\tsrcDir:'c:/projects/hello/source', //where *.as files are located\n\tmainFile:'/com/foo/Hello.as', //main class file relative location to srcDir\n\texpose:'hello', //module export name\n\tplatform:'node' //environment where compiled js will run, options: \"node|browser|player\"\n}\n\nlet result = as3_js.compile(props);\n\nfs.writeFileSync('c:/projects/hello/tools/modules/hello/index.js', result.js, 'utf8');\n```\n\n```javascript\n/* node test module script */\n\nconst hello = require('./modules/hello');\n\ntrace(hello.say()); //outputs hello world to console\n```\n\n# Advanced Usage:\n\n*see docs*\n\n# Notes:\n\n* For the \"browser\" platform, recommend loading compiled js files in an iframe *(see docs for details)*\n* The original purpose of this project was to convert *valid* AS3 to JS, so consider first compiling with Apache Flex for improved error checking.\n* Outstanding bug: missing semicolons will cause compilation errors in some instances...recommend always using semicolons for now.\n* Recommended IDE: [IntelliJ][intellij]\n\n   [swc]: \u003chttps://en.wikipedia.org/wiki/Adobe_SWC_file\u003e\n   [with]: \u003chttps://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/statements.html#with\u003e\n   [intellij]: \u003chttps://www.jetbrains.com/idea/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbrandle%2Fas3-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnbrandle%2Fas3-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbrandle%2Fas3-js/lists"}