@afterswf/embed 0.0.0-stage → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2026 eXponenta and the AwayFL and afterswf contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,148 @@
1
- # Temporary Holding Version
1
+ AfterSWF
2
+ ========
3
+
4
+ AfterSWF is [Mesmotronic](https://mesmotronic.com)'s fork of [AwayFL](https://github.com/awayfl/awayfl-embed),
5
+ the open-source Flash player for the browser. It adds the following functionality to enable it to render more advanced AS3 content and make it a
6
+ better drop-in replacement for the original SWFObject.
7
+
8
+ ### A better drop-in replacement for SWFObject
9
+
10
+ | Feature | What you get |
11
+ |---|---|
12
+ | SWFObject 2.x | `swfobject` (and `swfObject`) supports `embedSWF`, `registerObject`, `createSWF`, `removeSWF`, `getObjectById`, `hasFlashPlayerVersion`, `getFlashPlayerVersion` (which reports Flash Player 32), `addDomLoadEvent`, `addLoadEvent` and `getQueryParamValue`, with SWFObject's callback behaviour |
13
+ | SWFObject 1.5 | `new SWFObject(swf, id, width, height, version, bgcolor)`, with `addParam`, `addVariable` and `write` |
14
+ | Hard-coded embeds | Flash `<object>` and `<embed>` markup is replaced with players, including markup added after the page has loaded |
15
+ | Flash parameters | `flashvars`, `bgcolor` and `scale` work as in Flash, except that `exactFit` crops like `noBorder`; others, such as `salign` and `wmode`, are accepted and ignored. Attributes such as `id`, `class` and `name` are kept |
16
+ | ExternalInterface | `ExternalInterface.call()` in AS2 and AS3 runs in the page, and functions added with `addCallback()` become methods of the player element, with their return values |
17
+ | Load errors | Errors loading a SWF fire the player element's `error` event |
18
+ | Loading screen | A plain loading bar in the page's text colour on a transparent background, instead of the AwayFL splash. Once loaded, the stage colour fills any space around the stage, as in Flash. Set `progress` to `false` to hide the bar, or `splash` to an image URL to show one |
19
+
20
+ ### More advanced AS3 content
21
+
22
+ | Feature | What you get | Package |
23
+ |---|---|---|
24
+ | Flash Remoting | `NetConnection.connect()` and `call()` work with HTTP(S) AMF gateways such as Zend_Amf and AMFPHP. Set `self.__AWAYFL_AMF_DEBUG = true` to log the traffic | [playerglobal](https://github.com/afterswf/playerglobal) |
25
+ | FlashVars | Available as `loaderInfo.parameters` in AS3 and as `_root` variables in AS1/2, along with any query string parameters in the SWF's URL | [playerglobal](https://github.com/afterswf/playerglobal), [avm1](https://github.com/afterswf/avm1) |
26
+ | `flash.utils.Proxy` | Subclasses' `flash_proxy` overrides are found, so dynamic property access works instead of throwing errors #2088–#2096 | [avm2](https://github.com/afterswf/avm2) |
27
+ | Lines | Miter, bevel and round joints and square and round caps render as in Flash, without notches at the corners, and `lineStyle` alpha is limited to 0–1 | [graphics](https://github.com/afterswf/graphics), [playerglobal](https://github.com/afterswf/playerglobal) |
28
+ | Colour transforms | Colours are clamped as in Flash, so an alpha above 1 no longer distorts them | [renderer](https://github.com/afterswf/renderer) |
29
+ | HTML text | Entities such as `&amp;`, `&lt;` and `&#163;` in `htmlText` display as in Flash | [scene](https://github.com/afterswf/scene) |
30
+ | Event targets | Events from an aggregated `EventDispatcher` report the right `currentTarget`, which GreenSock relies on | [playerglobal](https://github.com/afterswf/playerglobal) |
31
+ | Mouse cursors | `flash.ui.MouseCursorData` is available, so `Mouse.registerCursor` works | [playerglobal](https://github.com/afterswf/playerglobal) |
32
+ | Removing children | `removeChild` no longer throws error #2025 for children that have already been detached internally, which could stop playback | [playerglobal](https://github.com/afterswf/playerglobal) |
33
+ | AS1/2 | SWFs loaded with `loadMovie` use their own symbols, `setNewTextFormat` only changes the properties that are set, and the drawing API no longer throws errors | [avm1](https://github.com/afterswf/avm1) |
34
+
35
+ ### Using it as a module
36
+
37
+ The embed script is also an ES module, which exports `swfobject` (and `swfObject`), `SWFObject`,
38
+ `AwayPlayerComponent`, `configure()` and `VERSION`. For example, from [jsDelivr](https://www.jsdelivr.com):
39
+
40
+ ```html
41
+ <div id="game"></div>
42
+
43
+ <script type="module">
44
+ import { swfobject } from 'https://cdn.jsdelivr.net/npm/@afterswf/embed/dist/embed.mjs';
45
+
46
+ swfobject.embedSWF('game.swf', 'game', 550, 400, '9.0.0', null, { level: 1 });
47
+ </script>
48
+ ```
49
+
50
+ The player loads its runtime and assets from the same folder as the module. Pin a version in production,
51
+ e.g. `@afterswf/embed@0.1.4`.
52
+
53
+ With a bundler, install `@afterswf/embed` and either serve its `dist/` folder or point `runtimeBaseUrl` at it.
54
+
55
+ Importing it also defines the global `swfobject`, so existing scripts on the page keep working, and
56
+ `configure()` takes the same options as `AWAY_EMBED_CFG`.
57
+
58
+ ### Building
59
+
60
+ The fixes live in the [afterswf](https://github.com/afterswf) forks of avm1, avm2, graphics, playerglobal,
61
+ renderer and scene. Until they're published to npm as `@afterswf/*`, `package.json` points the original
62
+ package names (`@awayfl/avm1`, `@awayjs/graphics` etc.) at local checkouts in sibling folders (`../avm1`
63
+ etc.), so this repo and every package it bundles use the forks.
64
+
65
+ Install each checkout's dependencies first; `npm install` here then builds their `dist/` folders through
66
+ their `prepare` scripts:
67
+
68
+ ```sh
69
+ # in each of ../avm1, ../avm2, ../graphics, ../playerglobal, ../renderer and ../scene
70
+ npx yarn@1 install --frozen-lockfile
71
+ ```
72
+
73
+ To build without the sibling checkouts, point the packages at the published forks instead
74
+ (`"@awayfl/avm2": "npm:@afterswf/avm2@^0.2.241"` etc.), or at GitHub for unreleased changes
75
+ (`"@awayfl/avm2": "github:afterswf/avm2#main"` etc.), which npm will clone, build and pack.
76
+
77
+ To publish a release, follow [RELEASING.md](./RELEASING.md).
78
+
79
+ The build uses the official `@rollup/plugin-typescript` instead of `rollup-plugin-typescript2`, which fails
80
+ with current versions of Node and rollup, and pins rollup and TypeScript to versions known to work.
81
+
82
+ ---
83
+
84
+ # Original AwayFL README
85
+
86
+ AwayFL helps you save your Flash games and keep them running after 2020!
87
+
88
+ Check your game on:
89
+ https://awayfl.org/swf-tester/
90
+
91
+ __How to use__
92
+
93
+ There are 3 main ways to use AwayFL on your site:
94
+
95
+ 1. [As a drop-in replacement for SWFObject](./example/index.html)
96
+ * Load the AwayFL player instead of, or as well as, `swfobject.js` (either order works). For example:
97
+ `<script src="../dist/embed.js"></script>`
98
+ * Existing [SWFObject](https://web.archive.org/web/20140704095451if_/http://code.google.com/p/swfobject/wiki/documentation#STEP_3:_Embed_your_SWF_with) code then embeds AwayFL players instead of Flash. For example:
99
+ `swfobject.embedSWF('Embedded.swf', 'container', '550', '400', '9.0.0', null, {name: 'value'});`
100
+ * SWFObject 2.x, as `swfobject` and `swfObject`: `embedSWF`, `registerObject` (static publishing), `createSWF`, `removeSWF`, `getObjectById`, `getFlashPlayerVersion` (reports 32.0.0), `hasFlashPlayerVersion`, `addDomLoadEvent`, `addLoadEvent`, `getQueryParamValue`, `createCSS`, `switchOffAutoHideShow`, `enableUriEncoding` and `ua`. As with SWFObject, callbacks run once the player element has been created, with `success: false` if it couldn't be; errors loading the SWF are reported by the element's `error` event.
101
+ * SWFObject 1.5: `new SWFObject(swf, id, width, height, version, bgcolor)`, with `addParam`, `addVariable` and `write(elementId)`.
102
+ * Hard-coded Flash `<object>` and `<embed>` markup is replaced with players too, including markup added to the page later. To turn this off, set `AWAY_EMBED_CFG.autoUpgrade = false`.
103
+ * Flash parameters (`<param>`s, SWFObject's `params`, or `<embed>` attributes):
104
+ * `flashvars` become `loaderInfo.parameters` in AS3 and `_root` variables in AS1/2, as do any query string parameters in the SWF's URL
105
+ * `bgcolor` overrides the SWF's background colour, and `scale` sets the stage's scale mode (`salign` isn't supported yet, so the stage is centred)
106
+ * others, such as `wmode`, `allowScriptAccess` and `quality`, are accepted and ignored
107
+ * Attributes such as `id`, `class` (or SWFObject's `styleclass`), `name` and `style` are copied onto the `<awayfl-player>` element.
108
+ * `ExternalInterface` (AS2 and AS3) connects to the page as it did with the Flash plugin: `ExternalInterface.call()` runs in the page, and functions added with `ExternalInterface.addCallback()` become methods of the player element, e.g. `swfobject.getObjectById('game').myCallback()`.
109
+ * Whether a SWF needs AVM1 (AS1/2) or AVM2 (AS3) is detected automatically.
110
+ * Optional: Configure AwayFL using the `AWAY_EMBED_CFG` variable.
111
+ This allows you to customize AwayFL's behavior. For a list of available options, see the [IBindingConfig interface](./src/embed/AwayPlayerComponent.ts).
112
+
113
+ 2. Using the AwayFL loader and a custom config:
114
+ * Grab the template from [/src/embed/embed.html](./src/embed/embed.html)
115
+ * Replace `__LOADER_URL__` with the URL of the AwayFL loader script (`loader.js`)
116
+ * Replace `__GAME_CONFIG__` with a game configuration JSON (or object) conforming to the [AwayFL config interface](./src/loader/iConfigBase.ts).
117
+ * To run your game, add a `GAME` resource record to the `binary` array of the game configuration.
118
+ * Example: `{path: path/to/game.swf, resourceType:'GAME'}`
119
+ * If your game uses external fonts, you will need to create separate SWF file(s) containing these fonts, then add font resource records to the `binary` array.
120
+ * Example: `{path: path/to/font.swf, resourceType:'FONTS'}`
121
+
122
+ Full Example:
123
+ ```
124
+ const gameConfig = {
125
+ width: 550,
126
+ height: 400,
127
+ splash: './splash.png',
128
+ progress: { // optional
129
+ back: 'cover url(./progressBack.png)',
130
+ line: #cc0022, // or image, it will passed to progressLine background,
131
+ rect: [0, 0.9, 1, 0.1] // x, y, width, height of preogress line relative container
132
+ },
133
+ baseUrl: '../dist',
134
+ runtime: ['../dist/runtime.js'],
135
+ binary: [{
136
+ path: 'Embedded.swf',
137
+ resourceType: 'GAME',
138
+ name: 'Game', // not used atm
139
+ meta: {} // not used atm
140
+ }],
141
+ }
142
+ ```
143
+
144
+ 3. Creating a custom loader that loads SWF data from an ArrayBuffer:
145
+ * Load the AwayFL runtime from `dist/runtime.js`
146
+ * Construct the player: `const player = new AWAYFL.Player();`
147
+ * Call `player.loadBuffer(arrayBuffer);`
2
148
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.