swf-loader
v1.0.2
Published
SWF loader module for Webpack
Downloads
2
Readme
SWF Loader for Webpack
Generates an asset library from a .swf file that may be loaded by OpenFL.
Usage
Install this swf-loader module into your Webpack project using the following command.
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.
module: {
rules: [
{ test: /\.swf$/, loader: 'swf-loader' }
]
}
Finally, import a .swf file and load it using the openfl.utils.AssetLibrary
class.
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));
}
}