User Tools

Site Tools


This is an old revision of the document!

Compiling the examples for Flash from Windows

Adobe's new Flash C++ stuff (Flascc?) finally lets you pop get your Proton apps up on the web!

  • Games run in Flash with 0 source code or media changes (except all sounds must be .mp3 at the moment, see gotchas below)
  • Graphics are hardware accelerated, using Seth's GLESAdaptor which uses Stage3D shaders to emulate GLES 1.X behind the scenes
  • Converts GL_TRIANGLE_FAN and GL_TRIANGLE_STRIP to normal triangles on the fly
  • Internally creates and caches VBOs when it can
  • Build process hacked to show better errors than the one Adobe came with
  • Uses the cygwin that comes with the Flash C++ SDK, so you don't have to install your own
  • Mouse/keyboard input, EnterForeground/EnterBackground type messages and such all properly handled
  • Uses Adobe's default preloader, but you could change that
  • Can also run in a simple text console only mode, see RTConsole example for that

Ok, it's assumed you've already built things on Windows and understand how Proton works.

It's not a perfect emulation (it's still a work in progress), but all the Proton examples run fine, so it ain't bad either.

NOTE : Proton using Domain Memory and Stage3D acceleration and Adobe has a rule that if your app makes 50k+ you have to pay them 9 percent. Just warning ya. Because of this, I (Seth) will probably be adding other web targets as well instead of depending on just Flash.

Flascc works for OSX or Windows, but I'm only going to cover the Windows setup as that's what I use. It uses Cygwin, which is sort of a fake linux for Windows. But, the Flascc SDK comes with its own version so you don't have to install it separately, like we used to have to do for Android builds.

Before you whip out .swf's of the Proton examples and amaze everyone, make sure the SDK is working.

  • Install the Adobe Flash C++ Compiler (It's free, but Adobe makes you create an account here to get it)
  • Install the latest FLEX SDK (Link)
  • Optional: Download the debug Flash projector and put it in /shared/flash, associate that with .swf
  • Optional: Download Vizzy, it will show LogMsg messages when using a debug player
  • Follow this and make sure you can compile the 01_HelloWorld example

Note: If you get error “LLVM ERROR: Error: Unable to launch the Java Virtual Machine.” then modify 01_HelloWorld\Makefile to add -jvmopt=-Xmx1G to the build commands, so in the end, it would look like this:

T01: check
	@echo "-------- Sample 1 --------"
	@echo && echo "First let's compile it as a projector:"
	"$(FLASCC)/usr/bin/gcc" -jvmopt=-Xmx1G $(BASE_CFLAGS) hello.c -o hello.exe

	@echo && echo "Now lets compile it as a SWF:"
	"$(FLASCC)/usr/bin/gcc" -jvmopt=-Xmx1G $(BASE_CFLAGS) hello.c -emit-swf -swf-size=200x200 -o hello.swf

include ../Makefile.common

	rm -f hello.swf hello *.bc *.exe

Now it should work. But if you get it later with more complex builds, it's because Adobe hardcoded -Xmx1500M as a setting inside of G++.exe and friends. I actually hex-edited mine to fix it as my java setup couldn't handle 1.5 gb for whatever reason, but there must be a better way…

Misc Notes & Gotchas

  • Don't try to rename, the default preloader that Adobe ships hardcodes this name, we'd better keep it. (At first I tried to rename it, bad idea..)
  • shared/flash/app/flash/ is the normal one, shared/flash/app/flash/RTConsoleVersion/ is a special version that just does console output, no Stage3D or audio support, the RTConsole example uses it
  • If you get reference errors in release builds you need to add the names of those functions to your project/flash/export.txt file. This will stop them from getting stripped out.
  • printf will act like LogMsg, both will go to debug output
  • Some MSVC examples have a Flash GLES Debug profile setup, it compiles and renders with MSVC, but there is no video as it's all going through a crippled GLFlashAdaptor - you can't see anything, but it's useful to me for debugging and seeing which GLES things aren't handled yet.
  • Only 128kz stereo mp3 audio is supported
  • SetVolume, SetPan, IsPlaying on AudioManagerFlash not implemented
  • Not all GL functions supported
  • Only one light is supported and it must be ambient
  • LaunchURL works, but only when loading the swf from a real website, otherwise you get a security error
  • It's slow.. I get 60 fps but only because I have a top of the line machine.. there are many optimizations I can still make, especially in the GLES1Adaptor code.
proton/flash_setup.1355235937.txt.gz · Last modified: 2012/12/11 14:25 by seth