1.0.2 • Published 7 months ago

swf-loader v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
7 months ago

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));
	}
}