Testing SWF in browser rather than stand-alone flash player is possible?

Hi, I’m trying to test a swf in the browser rather in the standalone flash player. Just a very basic setup, right now I’m doing…
openfl test flash
Which opens my swf in the standalone player.

I see in the haxe installation folder there is a folder called…
/usr/lib/haxe/openfl/3,3,6/templates/flash/templates/chrome
…containing index.html, swfobject.js, etc. So it looks like openfl is able to publish straight to the browser. I just can’t find any documentation on how to do it. Any ideas?

Note: Why do I want to publish to the browser? My swf is doing user authentication with a local dev server, but the standalone player doesn’t seem to send cookies when making URLRequests, so sessions can’t persist. Running in the browser solves this. Why not just open the swf manually in Chrome myself? I’m debugging with IntelliJ which publishes using the openfl commandline.

Nothing to do with OpenFL (I think). Look at your mime settings.
If I grep swf in /usr/share/applications, I get:
flashplayerdebugger.desktop:MimeType=application/swf-flash;application/x-shockwave-flash;
mimeinfo.cache:application/swf-flash=flashplayerdebugger.desktop;

Deleting/renaming the desktop file would be enough I guess.

You could place your own .html file in the bin/flash/bin folder, add embed tags and use openfl build flash command. Open the html in your browser and refresh after each compilation.

Oh nice idea Milton, nice n simple. I did that and it does open the swf in Chrome. But my swf needs direct-blit mode (it’s a Starling app), and in a browser this must be enabled using HTML/JavaScript (wmode=direct) in the swf’s containing html. You can’t just set the swf-direct-blit flag in project.xml when compiling the swf.

I would do this hcwdikk, but then i wouldn’t be able to step-through debug the swf (super necessary!)

Looking at the index.html in the templates folder i mentioned, it contains template variables to deal with things like swf dimensions, frame rate, etc. That to me strongly suggests that openfl is designed to publish to the browser. Some little switch somewhere! Hmm.

Maybe look at /usr/lib/haxe/lib/lime/2,9,1/lime/tools/platforms/FlashPlatform.hx:

if (project.targetFlags.exists ("web")) {
    targetPath = "index.html";
}
1 Like

Thank you Milton, target flags, that was the clue I was looking for! The way to do it is…
openfl test flash -web
Seems so simple but I still can’t find it documented anywhere.

For me that used the template…
/usr/lib/haxe/openfl/3,3,6/templates/flash/templates/web/index.html
That template had no variable for the swf’s attributes so I had to add that in, setting it to {wmode: "direct"}
Also, for some reason my project.xml wouldn’t let me override the template file with my own, so I had to edit the original. I’m sure that’ll come back to bite me on the nipple.

Thanks for your help both of you, really appreciated.

Sidenote: If you’re using IntelliJ then you can set the web target flag in the IDE in the Project Structure > Modules > Haxe > OpenFL settings item called OpenFL arguments, entering the same thing: -web