@afterswf/embed 0.0.0-stage → 0.1.4
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 +21 -0
- package/README.md +142 -2
- package/dist/HISTORY.txt +2190 -0
- package/dist/VERSIONS.txt +16 -0
- package/dist/assets/builtins/avmplus.abc +0 -0
- package/dist/assets/builtins/builtin.abc +0 -0
- package/dist/assets/builtins/playerglobal.abcs +0 -0
- package/dist/assets/builtins/playerglobal.json +2753 -0
- package/dist/assets/fonts.swf +0 -0
- package/dist/assets/progressBg.jpg +0 -0
- package/dist/assets/progressLine.jpg +0 -0
- package/dist/assets/splash.jpg +0 -0
- package/dist/embed.js +2 -0
- package/dist/embed.js.map +1 -0
- package/dist/embed.mjs +2 -0
- package/dist/embed.mjs.map +1 -0
- package/dist/loader.js +2 -0
- package/dist/loader.js.map +1 -0
- package/dist/runtime.js +37 -0
- package/dist/runtime.js.map +1 -0
- package/dist/version.mjs +1 -0
- package/package.json +91 -3
- package/types/index.d.ts +145 -0
- package/types/version.d.ts +5 -0
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,143 @@
|
|
|
1
|
-
|
|
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`, `scale` and `salign` work as in Flash; others, such as `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
|
+
|
|
19
|
+
### More advanced AS3 content
|
|
20
|
+
|
|
21
|
+
| Feature | What you get | Package |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| 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) |
|
|
24
|
+
| 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) |
|
|
25
|
+
| `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) |
|
|
26
|
+
| 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) |
|
|
27
|
+
| Colour transforms | Colours are clamped as in Flash, so an alpha above 1 no longer distorts them | [renderer](https://github.com/afterswf/renderer) |
|
|
28
|
+
| HTML text | Entities such as `&`, `<` and `£` in `htmlText` display as in Flash | [scene](https://github.com/afterswf/scene) |
|
|
29
|
+
| Event targets | Events from an aggregated `EventDispatcher` report the right `currentTarget`, which GreenSock relies on | [playerglobal](https://github.com/afterswf/playerglobal) |
|
|
30
|
+
| Mouse cursors | `flash.ui.MouseCursorData` is available, so `Mouse.registerCursor` works | [playerglobal](https://github.com/afterswf/playerglobal) |
|
|
31
|
+
| 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) |
|
|
32
|
+
|
|
33
|
+
### Using it as a module
|
|
34
|
+
|
|
35
|
+
The embed script is also an ES module, which exports `swfobject` (and `swfObject`), `SWFObject`,
|
|
36
|
+
`AwayPlayerComponent`, `configure()` and `VERSION`. For example, from [jsDelivr](https://www.jsdelivr.com):
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<div id="game"></div>
|
|
40
|
+
|
|
41
|
+
<script type="module">
|
|
42
|
+
import { swfobject } from 'https://cdn.jsdelivr.net/npm/@afterswf/embed/dist/embed.mjs';
|
|
43
|
+
|
|
44
|
+
swfobject.embedSWF('game.swf', 'game', 550, 400, '9.0.0', null, { level: 1 });
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The player loads its runtime and assets from the same folder as the module. Pin a version in production,
|
|
49
|
+
e.g. `@afterswf/embed@0.1.4`.
|
|
50
|
+
|
|
51
|
+
With a bundler, install `@afterswf/embed` and either serve its `dist/` folder or point `runtimeBaseUrl` at it.
|
|
52
|
+
|
|
53
|
+
Importing it also defines the global `swfobject`, so existing scripts on the page keep working, and
|
|
54
|
+
`configure()` takes the same options as `AWAY_EMBED_CFG`.
|
|
55
|
+
|
|
56
|
+
### Building
|
|
57
|
+
|
|
58
|
+
The fixes live in the [afterswf](https://github.com/afterswf) forks of avm1, avm2, graphics, playerglobal,
|
|
59
|
+
renderer and scene. Until they're published to npm as `@afterswf/*`, `package.json` points the original
|
|
60
|
+
package names (`@awayfl/avm1`, `@awayjs/graphics` etc.) at local checkouts in sibling folders (`../avm1`
|
|
61
|
+
etc.), so this repo and every package it bundles use the forks.
|
|
62
|
+
|
|
63
|
+
Install each checkout's dependencies first; `npm install` here then builds their `dist/` folders through
|
|
64
|
+
their `prepare` scripts:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
# in each of ../avm1, ../avm2, ../graphics, ../playerglobal, ../renderer and ../scene
|
|
68
|
+
npx yarn@1 install --frozen-lockfile
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
To build without the sibling checkouts, point the packages at GitHub instead
|
|
72
|
+
(`"@awayfl/avm2": "github:afterswf/avm2#main"` etc.), and npm will clone, build and pack them.
|
|
73
|
+
|
|
74
|
+
The build uses the official `@rollup/plugin-typescript` instead of `rollup-plugin-typescript2`, which fails
|
|
75
|
+
with current versions of Node and rollup, and pins rollup and TypeScript to versions known to work.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
# Original AwayFL README
|
|
80
|
+
|
|
81
|
+
AwayFL helps you save your Flash games and keep them running after 2020!
|
|
82
|
+
|
|
83
|
+
Check your game on:
|
|
84
|
+
https://awayfl.org/swf-tester/
|
|
85
|
+
|
|
86
|
+
__How to use__
|
|
87
|
+
|
|
88
|
+
There are 3 main ways to use AwayFL on your site:
|
|
89
|
+
|
|
90
|
+
1. [As a drop-in replacement for SWFObject](./example/index.html)
|
|
91
|
+
* Load the AwayFL player instead of, or as well as, `swfobject.js` (either order works). For example:
|
|
92
|
+
`<script src="../dist/embed.js"></script>`
|
|
93
|
+
* 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:
|
|
94
|
+
`swfobject.embedSWF('Embedded.swf', 'container', '550', '400', '9.0.0', null, {name: 'value'});`
|
|
95
|
+
* 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.
|
|
96
|
+
* SWFObject 1.5: `new SWFObject(swf, id, width, height, version, bgcolor)`, with `addParam`, `addVariable` and `write(elementId)`.
|
|
97
|
+
* 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`.
|
|
98
|
+
* Flash parameters (`<param>`s, SWFObject's `params`, or `<embed>` attributes):
|
|
99
|
+
* `flashvars` become `loaderInfo.parameters` in AS3 and `_root` variables in AS1/2, as do any query string parameters in the SWF's URL
|
|
100
|
+
* `bgcolor` overrides the SWF's background colour, and `scale` and `salign` set the stage's scale mode and alignment
|
|
101
|
+
* others, such as `wmode`, `allowScriptAccess` and `quality`, are accepted and ignored
|
|
102
|
+
* Attributes such as `id`, `class` (or SWFObject's `styleclass`), `name` and `style` are copied onto the `<awayfl-player>` element.
|
|
103
|
+
* `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()`.
|
|
104
|
+
* Whether a SWF needs AVM1 (AS1/2) or AVM2 (AS3) is detected automatically.
|
|
105
|
+
* Optional: Configure AwayFL using the `AWAY_EMBED_CFG` variable.
|
|
106
|
+
This allows you to customize AwayFL's behavior. For a list of available options, see the [IBindingConfig interface](./src/embed/AwayPlayerComponent.ts).
|
|
107
|
+
|
|
108
|
+
2. Using the AwayFL loader and a custom config:
|
|
109
|
+
* Grab the template from [/src/embed/embed.html](./src/embed/embed.html)
|
|
110
|
+
* Replace `__LOADER_URL__` with the URL of the AwayFL loader script (`loader.js`)
|
|
111
|
+
* Replace `__GAME_CONFIG__` with a game configuration JSON (or object) conforming to the [AwayFL config interface](./src/loader/iConfigBase.ts).
|
|
112
|
+
* To run your game, add a `GAME` resource record to the `binary` array of the game configuration.
|
|
113
|
+
* Example: `{path: path/to/game.swf, resourceType:'GAME'}`
|
|
114
|
+
* 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.
|
|
115
|
+
* Example: `{path: path/to/font.swf, resourceType:'FONTS'}`
|
|
116
|
+
|
|
117
|
+
Full Example:
|
|
118
|
+
```
|
|
119
|
+
const gameConfig = {
|
|
120
|
+
width: 550,
|
|
121
|
+
height: 400,
|
|
122
|
+
splash: './splash.png',
|
|
123
|
+
progress: { // optional
|
|
124
|
+
back: 'cover url(./progressBack.png)',
|
|
125
|
+
line: #cc0022, // or image, it will passed to progressLine background,
|
|
126
|
+
rect: [0, 0.9, 1, 0.1] // x, y, width, height of preogress line relative container
|
|
127
|
+
},
|
|
128
|
+
baseUrl: '../dist',
|
|
129
|
+
runtime: ['../dist/runtime.js'],
|
|
130
|
+
binary: [{
|
|
131
|
+
path: 'Embedded.swf',
|
|
132
|
+
resourceType: 'GAME',
|
|
133
|
+
name: 'Game', // not used atm
|
|
134
|
+
meta: {} // not used atm
|
|
135
|
+
}],
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
3. Creating a custom loader that loads SWF data from an ArrayBuffer:
|
|
140
|
+
* Load the AwayFL runtime from `dist/runtime.js`
|
|
141
|
+
* Construct the player: `const player = new AWAYFL.Player();`
|
|
142
|
+
* Call `player.loadBuffer(arrayBuffer);`
|
|
2
143
|
|
|
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.
|