Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load the resources of a game that is not in the same folder as awayfl #2

Open
Stefannag opened this issue Oct 27, 2022 · 3 comments
Open

Comments

@Stefannag
Copy link

Hi,

How to set a base for the assets of a game? For example, the awayfl is located in the '/emulators/awaylf' folder, and the game is located in 'games/arandomgame/game.swf'. In the game folder, we have some assets like 'games/arandomgame/assets/sound.swf'.

If in awayfl I enter the path of the game.swf, I will get an error 404 telling me that the emulator didn't find the sound.swf in the 'emulators/awayfl/assets' folder. But that file is located in the game path, not awayfl path.

How can I specify the base path for the game/assets?

@eXponenta
Copy link
Member

eXponenta commented Oct 27, 2022

You should use AWAY.Player manual for this case.

There are a some rules in Loader class:

https://github.com/awayfl/playerglobal/blob/dev/lib/display/Loader.ts#L506

https://github.com/awayfl/away-player-embed/blob/master/src/runtime.ts#L25

that can passed to runtime manually follow rule structure:

https://github.com/awayfl/swf-loader/blob/dev/lib/redirectResolver.ts#L10

as redirects field in constructor config:

https://github.com/awayfl/swf-loader/blob/ce7e8aa1a095e66046b9a819c560c15474650c44/lib/AVMStage.ts#L421

this means than you should call:

const player = new AWAYFL.player(containerNode, {
   redirects: [
        test: ( url ) => url && url.contains('*.swf'),
        resolve: (url ) => 'games/arandomgame/assets/' + url.substring( url.lastIndexOf('/'))
   ]
}) ;

This will redirect any url's of nested resources by specific rule, because sometimes SWF has absolute path, or try load from hardcoded url.

@eXponenta
Copy link
Member

You can use embed template and replace all configuration and runtime pathes
https://github.com/awayfl/away-player-embed/blob/master/src/embed/embed.html#L35

@Stefannag
Copy link
Author

Uhm, ok. I will try to see if I can get to a solution. Thanks for the time! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants