HTML5 target, passing vars to stage.loaderInfo.parameters

So, what is the best way to pass parameters from a page to a HTML5 / Flash app on that page?

Perhaps we should expand the openfl.embed JavaScript function to accept embed parameters, or I wonder if there would be a better place to put it

Using the lime.embed function to pass additional variables sounds like the best solution. Mostly because it will resemble the way it is being done now with Flash and swfobject…

Bump…
I was referring to this link : http://api.openfl.org/openfl/display/LoaderInfo.html#parameters

Which says that query string is source of parameter for html target, and then I saw this thread from 2014…

I need to know, if in the latest version, is their any way to pass variables into the application via the index.html file’s code, instead of passing it through the URL ?

And with reference to the above post, how can I use lime.embed to pass parameter ? I am not able to find much information on this.

It looks like <window parameters="" /> will pass as a String value to the Flash target embed parameters, but is available on HTML5 only using stage.window.config.parameters, and does not populate through loaderInfo.parameters as an object.

I am open to suggestions for a better embed command, this does seem like an important omission

Hmm… It works when i use <window parameters="45454..." /> in project.xml . But is their anything I can use inside index.html ? I tried using window.config.parameters = “abcd” in index.html. And traced stage.window.config.parameters , but that doesn’t work, as both variables are not related, if I guess right.

In my case, the index.html is dynamically generated on the server. So that’s the only thing I can use for pushing in the variables. I think, I should try for getting the variables from the URL itself.

For now, I think, best option is to get the value from the URL directly.

Browser.window.document.documentURI

For now, this works for me and can be used inside the OpenFL code.

1 Like

You might be able to use a DOM element, or a URI on your application JS tag, instead of the URL

(in case the user can change the URL and remove your variable)