swf-loader

1.0.2 • Public • Published

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

Dependencies (3)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i swf-loader

    Weekly Downloads

    1

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    6.01 kB

    Total Files

    6

    Last publish

    Collaborators

    • bowlerhatllc
    • jgranick