https://github.com/openfl/swf-loader
SWF loader for OpenFL projects built with Webpack
https://github.com/openfl/swf-loader
openfl swf webpack-loader
Last synced: 12 months ago
JSON representation
SWF loader for OpenFL projects built with Webpack
- Host: GitHub
- URL: https://github.com/openfl/swf-loader
- Owner: openfl
- License: mit
- Created: 2018-01-09T21:03:32.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-01-02T17:22:28.000Z (over 1 year ago)
- Last Synced: 2025-06-12T08:23:05.774Z (about 1 year ago)
- Topics: openfl, swf, webpack-loader
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 4
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SWF Loader for Webpack
Generates an asset library from a _.swf_ file that may be loaded by [OpenFL](https://www.npmjs.com/package/openfl).
# Usage
Install this _swf-loader_ module into your Webpack project using the following command.
```sh
npm install --save-dev swf-loader
```
Then, in your _webpack.config.js_ file, add the following rule to allow _.swf_ files to be imported using _swf-loader_.
```js
module: {
rules: [
{ test: /\.swf$/, loader: 'swf-loader' }
]
}
```
Finally, import a _.swf_ file and load it using the `openfl.utils.AssetLibrary` class.
```js
import Sprite from "openfl/display/Sprite";
import AssetLibrary from "openfl/utils/AssetLibrary";
import myLibraryPath from "./assets/myLibrary.swf";
class MySprite extends Sprite {
constructor() {
super();
AssetLibrary.loadFromFile(myLibraryPath)
.onComplete((library) => {
const mc = library.getMovieClip("MyAnimation");
this.addChild(mc);
})
.onError(e => console.error(e));
}
}
```