Skip to content

Passing params to the SWF #4

@nicksterious

Description

@nicksterious

I have a SWF that tries loading something from the server but needs a param with a relative path to load from, something I'd pass as:

<param name="base" value="/my/relative/path/data.txt" />

Without this parameter it will always try loading from the browser URL, eg:
https://www.example.com/play-game/my-game-name,

... despite the SWF being at /my/relative/path/.

My code:


<script src="/awayfl/loader.js"></script>
<script>
	const config = {
		width: 800,
		height: 600,
		splash: '/awayfl/splash.png',
		progress: { // optional
			back: 'cover url(/awayfl/progressBack.png)',
			line: #cc0022, // or image, it will passed to progressLine background,
			rect: [0, 0.9, 1, 0.1] // x, y, width, height of preogress line relative contianer 
		},
		baseUrl: '/awayfl/',
		runtime: ['/awayfl/runtime.js'],
		binary: [{
			path: '/my/relative/path/example.swf',
			resourceType: 'GAME',
			name: 'Game', // not used atm
			meta: {} // not used atm
		}],
	};
	//window.addEventListener("load", () => {
		AWAYFL.LegacyLoader.init(config);
		AWAYFL.LegacyLoader.runGame((fill) => {
			window.dispatchEvent(new CustomEvent('awayfl-player-progress', {detail: fill}));
		}, (config, hideLoader) => {
			const player = new AWAYFL.Player(document, config);
			window.dispatchEvent(new CustomEvent('awayfl-player-init', {detail: player}));
			player
				.loadAndPlay()
				.then((_, hide) => {
					window.dispatchEvent(new CustomEvent('awayfl-player-load'));
					hide && hide();
				});				
		});
	//});
</script>

Now this is just an example of a parameter, I understand there are redirects we can use for this particular situation.

How about other parameters that configure the asset?

How do I pass parameters to SWF files?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions