Sunday, December 30, 2012

Migrating from Alchemy to FlasCC - Compiling C/C++ to SWC

New year, new tools! The updated new version of Alchemy, the C/C++ to AS3 compiler - FlasCC was released some time ago. Many things have been changed. These two tools - Alchemy and FlasCC have very different APIs. However, if you have some experience with the old Alchemy, migrating from it to FlasCC is not hard.

In this post I will share my experience of migrating from Alchemy to FlasCC. I ported the very classic Alchemy example to FlasCC - Ralph Hauwert's Alchemy lookup-table effects. I will use that example to show you how to compile C/C++ code to SWC, how to use FlasCC to manipulate screen buffers, as well as the changes of the APIs.

The installation of FlasCC has been greatly simplified. You don't need to install Cygwin separately like Alchemy because the new FlasCC tool is already integrated with Cygwin. First, you have to get the FlasCC tools at
Unzip the package to somewhere (mine is "D:\FlasCC_1.0.0"), click "run.bat", then you will open the Cygwin window.

Let compile the sample first:

cd 05_SWC
make FLASCC=/cygdrive/d/FlasCC_1.0.0/sdk FLEX=/cygdrive/d/Program\ Files/FlashDevelop/Tools/flexsdk
This sample is a very simple and good start. You should try to read the source code and the official notes:

To create a SWC from some C/C++ functions, we need to write some wrapper code (as3api.cpp) to expose the functions to AS3.
In Alchemy, it will be something in the C/C++'s main() function like this:
int main()
AS3_Val initializeScreenDiffuseBufferMethod = AS3_Function(NULL, initializeScreenDiffuseBuffer);
AS3_Val rasterizeMethod = AS3_Function(NULL, rasterize);
AS3_Val setupLookupTablesMethod = AS3_Function(NULL, setupLookupTables);
AS3_Val initializeDiffuseBufferMethod = AS3_Function(NULL, initializeDiffuseBuffer);
AS3_Val result = AS3_Object("initializeScreenDiffuseBuffer: AS3ValType, rasterize:AS3ValType,setupLookupTables:AS3ValType,initializeDiffuseBuffer:AS3ValType"
,initializeScreenDiffuseBufferMethod, rasterizeMethod,setupLookupTablesMethod,initializeDiffuseBufferMethod);
AS3_Release( initializeScreenDiffuseBufferMethod );
AS3_Release( rasterizeMethod );
AS3_Release( setupLookupTablesMethod );
AS3_Release( initializeDiffuseBufferMethod );
AS3_LibInit( result );
return 0;
While in FlasCC, it will be some declarations and wrapper functions outside the main function like this:
void rasterize_AS3() __attribute__((used,
annotate("as3sig:public function rasterize_AS3():void"),

void rasterize_AS3()

void setupLookupTables_AS3() __attribute__((used,
annotate("as3sig:public function setupLookupTables_AS3():void"),

void setupLookupTables_AS3()
And the main function in FlasCC:
int main()

The basic framework for using C/C++ to manipulate screen buffers:
1. Pass the texture's pixel data as ByteArray to C/C++ array.
2. Process the textures in C/C++.
3. Retrieve the screen buffer array (as bytearray) to flash and use a bitmap to render it.
The best way to pass bytearray between C/C++ and AS3 is to use pointers and C machine's RAM.

Please read the full source code of my example for details.

To pass parameters from AS3 to C/C++, and return the pointer of the array tBuffer (the screen buffer) in Alchemy:
AS3_Val initializeScreenDiffuseBuffer(void* self, AS3_Val args)
AS3_ArrayValue(args, "IntType, IntType", &resX, &resY);
tBuffer = malloc( resX * resY * sizeof(int) );
return AS3_Ptr(tBuffer);
In FlasCC:
int* initializeScreenDiffuseBuffer(int resX, int  resY)
tBuffer = (int*)malloc( resX * resY * sizeof(int) );
return tBuffer;//&(tBuffer[0]);//return the pointer to the screen buffer

void initializeScreenDiffuseBuffer_AS3() __attribute__((used,
annotate("as3sig:public function initializeScreenDiffuseBuffer_AS3(resX0:int,resY0:int):uint"),

void initializeScreenDiffuseBuffer_AS3()
int* result;
//copy the AS3 resolution variables resX0, resY0 (parameters of the swc function initializeScreenDiffuseBuffer_AS3) 
//to C variables resX, resY in lookupeffect.c
//get the pointer of the screen buffer
result = initializeScreenDiffuseBuffer(resX,resY);
// return the result (using an AS3 return rather than a C/C++ return)

Now let's see some differences of the AS3 APIs:
To initialize the C/C++ SWC Lib in Alchemy:
cLibInit = new CLibInit();
alcLookupLib = cLibInit.init();
In FlasCC:
To call the SWC functions:
alcDiffuseBitmapPointer = alcLookupLib.initializeScreenDiffuseBuffer(IMAGE_WIDTH,IMAGE_HEIGHT);
alcDiffuseBitmapPointer = initializeScreenDiffuseBuffer_AS3(IMAGE_WIDTH, IMAGE_HEIGHT); 
To use domain memory - the C machine's RAM (
var ns : Namespace = new Namespace( "cmodule.lookupeffect");
alchemyMemory = (ns::gstate).ds;
alchemyMemory.position = alcDiffusePointer;

alchemyMemory.position = alcDiffuseBitmapPointer;
screenDiffuseBitmapData.setPixels(screenDiffuseBitmapData.rect, alchemyMemory);
CModule.writeBytes(alcDiffusePointer, ba.length, ba);
CModule.readBytes(alcDiffuseBitmapPointer, 512 * 512 * 4, ba);
CModule.ram.position = alcDiffuseBitmapPointer;
screenDiffuseBitmapData.setPixels(screenDiffuseBitmapData.rect, CModule.ram);

The source code:


Wednesday, December 26, 2012

Bengine Race - Full Source Code of the Game and the Engine Released!

Here is the full source code for the game Bengine Race:

This release includes the C source code of the voxel engine - Bengine and the AS3 source code of the experimental game - Bengine Race.

You need Alchemy V0.5 (the "outdated" one, not FlasCC) to compile the C source code files to the swc.
You can find my backup of Alchemy Tools here:
Or try the Alchemy Repack for Win32:

Bengine is still under active development. This release is actually a very old version of Bengine. Since there is no schedule for an "official" release, I decided to share this early version first.

Sunday, December 23, 2012

Use HxSL/Stage3D to Create 2D Filters/Shaders

Update on 2014/01/04:
Many things changed since the original post was published. Now HaXe is 3.0 and HXSL reaches 2.0. So here is the updated source code of the example for HaXe 3 and HXSL 2:

Maybe you know how to use Pixel Bender in your Flash project to create some custom filters. Alternatively, with the new Stage3D API introduced in Flash 11, we can write 2D filters running with GPU. Here is the example:

The idea is simple: draw a plane using two triangles, upload the images you want to process as textures and do all the magic in your fragment shaders. I recommended you to try HxSL, an advanced shader language which has similar grammar to the Pixel Bender language. The above example - Poster Effect is ported from the Pixel Bender filter with only a few modifications of the original Pixel Bender filter code.

The full source code of the above example (HaXe/HxSL):
The source code of the Poster Shader in Pixel Bender Language:

Announcing HxSL:
Using Flash 3D API:

GIMP as Pixel Editor

Some notes and tips for using GIMP (2.8) as a Pixel Editor:

1. The Grid: View->Show Grid, Image->Configure Grid (Spacing 16x16)
2. The brush: Tools->Paint Tools->Pencil(N)/Eraser(Shift+E)
Windows->Dockable Dialogs->Tool Options->Brush->Pixel&Size->1.0
3. Preview: View->New View, View->Zoom
4. Palettes from images:
Windows->Dockable Dialogs->Palettes->Palettes Menu->Import Palette->
Select Source->Image(Must be an image already opened in GIMP)

Pixel Editors:

Saturday, September 29, 2012

An Introduction to Flash SDL

Emcmanus's Flash SDL (Simple DirectMedia Layer) using Alchemy V0.5 is very useful for porting C/C++ & SDL based games to Flash. Although Alchemy 2 (FlasCC) is coming soon, and it will have much better support for SDL, Emcmanus's simple Flash SDL library with Alchemy V0.5 just works fine for me now. So I think this simple tutorial for Flash SDL can still be helpful for some people.

1. Flash SDL Installation
You should correctly installed Alchemy V0.5 first. Then goto, download the repository zip, it should be "". Unzip, and
Copy "sdl/SDL.l.bc" to your Alchemy's lib directory, e.g., "D:\alchemy-cygwin-v0.5a\usr\local\lib",
(or within Cygwin "cp sdl/SDL.l.bc $ALCHEMY_HOME/usr/local/lib/")
Copy all header files in "sdl/include" to your Alchemy's include directory, e.g., "D:\alchemy-cygwin-v0.5a\usr\local\include"
(create this folder by yourself if it does exists, or within Cygwin "cp sdl/include/*.h $ALCHEMY_HOME/usr/local/include/")

Now let's test the sample project.
Open Cygwin Terminal, build the swc lib for our project:

cd /cygdrive/f/alchemy/emcmanus-flashsdl-04ce063/
source /cygdrive/d/alchemy-cygwin-v0.5a/alchemy-setup
gcc flashSDL.c -DFLASH -Isdl -lSDL -swc -O3 -o libSDL.swc
Run FlashDevelop and create a new AS3 project in the "emcmanus-flashsdl-04ce063" folder, set "" as the document class, and add "libSDL.swc" to Library.

Finally build & test the project, you should see a black screen with SDL's mouse icon:

Let see the author's comments for porting your SDL application to FlashSDL:
"Porting your SDL application to FlashSDL
Perhaps this is best understood by example. Examine ./flashsdl.c. Most immediately you will have to refactor your C application's main loop to run iteratively in the tick() method, assuming you end up using the application scaffolding in ./src/.
Make sure you've properly built and installed FlashSDL by building the test application. Then try running your application's ./configure.
Once you've successfully compiled, try linking the resuling SWC with the AS3 side of your application (which should be built on ./src/).
Other Tips
You have to set the color depth of your application to 32 Bits per pixel (in your call to SDL_SetVideoMode)."

Basically, the .as files in "./src/" folder is used to fetch the SDL's pixel buffer and display this buffer using a Flash bitmap at each frame. The "flashsdl.c" should be your skeleton for your own C/C++ project. Just move the initializing code into the setup() function and refactor the mainloop into the tick() method. You can also make use of those already declared variables in that file, such as using "TMPFLASH_screen" as your main screen buffer.

2. Displaying BMP Images in Flash SDL
The code in this section is based on Lazy Foo' tutorial:

(Flash) SDL has build-in BMP image support. To let the Flash SDL load a BMP image, we need to modify some AS3 code:
in "\src\sdl\"
internal var cLoader:CLibInit;
public var cLoader:CLibInit;
Then embed the image file and supply it to Alchemy - related AS code in modified "":
public static var hellobmpClass:Class;
this.libSDL = new LibSDL();
this.libSDL.cLoader.supplyFile("hello.bmp", new hellobmpClass());
Now you can load the image "hello.bmp" form C side normally. Please find the full C side code for loading and displaying the image in my source code package for this tutorial.
After adding the image loading and displaying code on the C side, recompile you will see something like this:

3. Playing Sound in Flash SDL
The Flash SDL does not have sound support yet on the C side.There is a fork on github which tried to add sound support,, but it is not usable yet and there is no updates for a long time. Noticing that most SDL applications are using SDL_mixer library instead of SDL_sound, I think a much wiser way is to use Flash's build in sound support instead of porting both libraries. You can also find my simple solution for playing "mp3" files in source code package (ALC_GE2D_PlaySound.c, flashSDL_sound.c), I just wrote some simple function calls to let the C function call the AS3 method for playing mp3.

4. True Type Font support and SDL_ttf in Flash SDL
Thanks to Emcmanus again, who has already ported the FreeType library to Flash, we can use the SDL_ttf library in Flash SDL to display true type font texts.

First, goto, download the compiled lib in the repository zip,
Copy "freetype.l.bc" into "D:\alchemy-cygwin-v0.5a\usr\local\lib",
Copy all header files in ".\src\c\freetype-2.3.9\include" to "D:\alchemy-cygwin-v0.5a\usr\local\include".

Then download the source file of SDL_ttf, form, put SDL_ttf.h SDL_ttf.c into the same folder of "flashSDL_sound_font.c", and include both files in "flashSDL_sound_font.c" using
#include "SDL_ttf.h"
#include "SDL_ttf.c"
After added some testing code for displaying text in "flashSDL_sound_font.c"'s setup method (please find the related C code in this tutorial's source code package, which are all based on, build the swc using some command like:
g++ flashSDL_sound_font.cpp -DFLASH -Ifreetype -Isdl -lfreetype -lSDL -swc -O3 -o libSDL.swc
Also embed and supply the font file to C:
public static var fontClass:Class;
this.libSDL.cLoader.supplyFile("lazy.ttf", new fontClass());
Recompile the swf, you will see the font displaying successfully:

Note: when using g++ to build the swc instead of gcc, you may need to edit some function declarations from "flashSDL_sound_font.c" to:
AS3_Val setup(void *data, AS3_Val args);//need arguments here!
AS3_Val quitApplication(void *data, AS3_Val args);//need arguments here!
AS3_Val tick(void *data, AS3_Val args);//need arguments here!
AS3_Val FLASH_getDisplayPointer(void *data, AS3_Val args);//need arguments here!

5. Fix the Arrow Keys Bug in Flash SDL
You may find that arrow key event will be ignored if you're using the precompiled "SDL.l.bc" provided by the author. This is very inconvenient since many game applications are heavily relying on arrow keys. To add arrow key support, find the "SDL_flashevents.c" file in "\emcmanus-flashsdl-04ce063\sdl\src\video\flash\" folder, goto the "FLASH_InitOSKeymap" function and add four lines for mapping arrow key events at the end of that function as below:
void FLASH_InitOSKeymap(_THIS)

keymap[38] = SDLK_UP;
keymap[40] = SDLK_DOWN;
keymap[37] = SDLK_LEFT;
keymap[39] = SDLK_RIGHT;
Recompile the "SDL.l.bc"
In sdl/:
make -f Makefile.flash clean all;
cd F:/alchemy/emcmanus-flashsdl-04ce063/sdl
Copy the compiled "SDL.l.bc" (F:\alchemy\emcmanus-flashsdl-04ce063\sdl) into "D:\alchemy-cygwin-v0.5a\usr\local\lib" and replace the old one. You can also find the updated "SDL.l.bc" in my source code package. If you don't want to recompile the whole Flash SDL library, simply copy mine and replace the old one.
After that, recompile the swc and your Flash project, arrow keys should work then.

6. Fix the supplyFile bug in Alchemy
This bug had been described by me here: The usual problem brought by the bug is that game saves can only be loaded once (if you use fopen on the C side) in each game session. You always need to restart the flash player (and hence your game) to load game saves if you have used the first opportunity. The bug is caused by that using "supplyFile" twice with the same file path won't work if you ever used "fopen" between the two "supplyFile"s.

To fix this bug, you need to modify the generated .as file by Alchemy as described in my old post:

First download the fixed version of "alc-asc" here:, put it into your "alchemy/achacks" folder, and search & replace the string "F:/alchemy/" to your Alchemy path (mine is "D:/alchemy-cygwin-v0.5a/").
When building the swc using Alchemy, keep the "" file, then open it, commentize the line "if(!res)" in the function "fetch", so the patched function should look like this:
private function fetch(path:String):Object
var res:Object = statCache[path];

var gf:ByteArray = gfiles[path];
Finally, recompile the ".as" file into the swc.
alc-asc libSDL.swc
With this patched swc, "supplyFile" will work well.

1. The source code package for this tutorial:

2. Two example SDL games ported to Flash (with full source code):

Infinite Balls:
Source Code:

Sword Girl:
Source Code:

3. Array @ARGV missing the @ in argument 1 of shift() at problem

4. Flash SDL FlasCC version: 

Friday, August 3, 2012

Jump To Pass - New 2.5D Game Powered by Z-Ground Engine Released!

Navigate the bouncing ball to pass over the road obstacles within the 60 seconds time limit. There is the no way backward.

Use less time to get high scores, this game has infinite number of randomly generated levels.

The camera view is "First Person", so the ball's on ground position is exactly the edge of the screen. Keep looking forward, make sure you won't fail on your next jump before pushing the ball. Use mouse control only is recommended.

Left Mouse Button Down (Hold) or Up Arrow Key to Push the Ball Forward
Move Mouse Left/Right or Left/Right Arrow Keys to Roll the Ball Left/Right
Right Click to Turn On/Off Bouncing/Menu Sound
Enter Key to Pause Game

Z-Ground is not dead!? 4 years after the first announcement of Z-Ground, the first game powered by the engine, with full source code, is finally released!

Z-Ground is the 2.5D Mode-7 engine I've been working on since 2008. At that time, there is no hardware acceleration, and flash 3D is not so common while many old school 3D tricks, such as mode-7, ray-casting, are popular among flash developers. I created Z-Ground engine for exploring these pseudo 3D technologies. But soon, lots of things changed rapidly in the flash world as you may know. Papervision, Sandy and Away3D came out, Flash 10 introduced some simple 3D API and finally there is Stage3D. Z-Ground is out-dated and actually I've stopped developing it much earlier than those big events because I found a much more exciting direction - voxel, that's why there are only a "prerelease" version and some demos released since 2008.

There is no "updates" of this release. The engine is almost the same as it was in 2008, just a little better than the prerelease version. The difference is the prerelease version used masks for ground slices, as many old mode-7 engines in flash 5-8 did, while the new one uses bitmapdata fill. So the new one should be much faster than the previous version.

The game "Jump To Pass" is firstly made for Kizi FGL Developer Competition - making a game in 48 hours, with theme "Passage" and "60 second (or less) time trial", "Mouse Control Only" as game rules. Then slighted modified for 2012 Mochi Summer Contest.

As I said, I've stopped to maintenance the engine - it is still slow and with limited function. There is no point to upgrade it for competing with modern flash 3D engines. I used it for making the game just for commemorating the first engine I worked on. The source package contains full source code of the game "Jump To Pass", as well as the engine's rendering core (but not everything, the full engine in 2008 is already much "advanced" than this, with sprite rendering, walls, ceiling, lighting, water, terrain, real 3D, simple physics and even a map editor. I may clean them up and release these functions later).

Download the source code:
Warning: The source code of the game is very messy, because it is a game made within 48 hours.

Thursday, August 2, 2012

Haxenme Installation Notes

1. Download the standalone installation package NME-3.4.0-Windows.exe at
(Haxe [2.10], Neko [1.8.2], NME [3.4.0], HXCPP [2.10], Actuate [1.43], SWF [1.13])

2. Click and run to install.
Tips: For updating NME from an older version, the simplest way is to download the new setup package, and reinstall. Uncheck the things that are already newest here, e.g., Haxe, Neko. Then select the same folder of the old installation.

3. Setup HaXe:
Go to D:\Motion-Twin\haxe, run haxesetup.exe

Done! Now let's test it.

4. Go to cmd:


5. Now download the sample file at
to test.
Unzip the source code "" to D:\TEST_PROJECTS\jgranick-PiratePig-9deb597.
cmd commands to build the swf:
cd D:\TEST_PROJECTS\jgranick-PiratePig-9deb597
nme test "Pirate Pig.nmml" flash

and to build html:nme test project.nmml html5

6. Use Flashdevelop for nme projects. (You should install Flashdevelop at first)
Open Flashdevelop and configure haxe path:

Open "Pirate Pig.hxproj" and build the project:

7. To use haxecpp target windows, you need to install VC++ (nme setup windows) at first.
After that
cd D:\TEST_PROJECTS\jgranick-PiratePig-9deb597
nme test "Pirate Pig.nmml" cpp

Alchemy v0.5a Installation Notes

Got a new notebook, so I will post some notes for future reference. Here is the one for Adobe Alchemy,

Environment: Windows 7.
Official Instructions:

1. Go to, download the "setup.exe" and install cygwin (to C:\cygwin) with the following packages:
zip (archive), gcc-g++, make (devel), perl.

2. Downloaded alchemy package at,
unzip it to D:\alchemy-cygwin-v0.5a.

3. Open Cygwin Terminal, input the following commands:
cd D:\alchemy-cygwin-v0.5a

4. Test alchemy with the commands to build the sample files:
source /cygdrive/d/alchemy-cygwin-v0.5a/alchemy-setup
cd D:/alchemy-cygwin-v0.5a/samples/HelloFlash
gcc HelloFlash.c -O3 -Wall -swf -o HelloFlash.swf


cd D:/alchemy-cygwin-v0.5a/samples/stringecho
gcc stringecho.c -O3 -Wall -swc -o stringecho.swc

It works and successfully generated the swf and swc files!

Thursday, June 14, 2012

Destructor - Voxel based FPS game power by Bengine for the 7DFPS!

Voxel based First Person Shooter created in Flash.

Destroy the world as much as you can! Less voxels remaining means higher score rank.
No enemies, no life bars, no bullets & time limits, just enjoy the shooting in the fully destructible environment. Be a Destructor!

Use "portals" (holes) on the ground to go to higher place.

Aim/Shoot: Left Mouse
Move/View: WSAD QEZX/Arrow Keys
Jump: Space
Pause Game: Enter (You can submit your scores in the pause menu.)

Download the SWF:

I've wanted to create a FPS game using Bengine since two years ago when I released the game "Bengine Race". Bengine was designed for FPS games but there was only one experimental "Racing" game made using it. The fact is that I didn't drop Bengine, I'm still developing on it silently when I have time. There were several new versions of the engine I used for the game "Bengine Race". I named them as "PBengine", "ASPBengine" and finally "ReBengine". In ASPBengine, I ported many Bengine's C code to AS3, such as the code for physics and controls, only leave the rendering core in C for speed. This game "Destructor" uses ReBengine, where "Re" stands for "Revert" instead of "Revision". For a long time I tried to optimize the engine for maximum speed at the cost of the graphics' quality. And when ASPBengine can run at above 60 FPS, I realized that the aliasing is intolerable. The low resolution of the original "Bengine" is already intolerable to many players, so I revert the rendering algorithm to the original "Bengine" and that's what "ReBengine" means.

ReBengine should be a litter faster than the original Bengine, though they use similar rendering algorithm. One difference is that ReBengine has more AS3, so it is much easier to compile and test. And the milestone is that ReBengine has a fully scriptable in-game voxel world editor, which is still under development.

Thanks to 7DFPS, it gives me a good motivation to make such a simple experimental FPS game. 7 days are enough for a good game, if you can work full time on it. It's a pity that I don't have much free time here to make my game complete. When I started, the rendering engine with simple physics was almost done, but there was still much to do for a game engine. I spent several days' free time and finished the game framework as well as the shooting prototype, and integrated them with Bengine. Running out of time for map design, I borrowed the map from Bengine Race. Hope you will enjoy it.

Credits: (for whatever helped to develop this game)
Adobe Alchemy
Boostworthy Animation System
Mochi Service

And ...

Saturday, June 2, 2012

Source Code of the Game - Wolf5k Flash

Description: A fast paced First Person Shooter. Classic FPS game Wolfenstein3D like first pernson shooting game.
Remake of Wolf5K in Flash.
Objective: Eliminate all enemies in the level to go to next level.
This game has infinite number of levels.
Enter key to view time, level, enemies left, total kills, life and score.
Mouse Move: Move
W/up: move forward
S/down: move back
Q/left: turn left
E/right: turn right
A/Z: strafe left
D/X: strafe right
Space/Right Click: shoot
Enter: pause game/view game status
M: show/hide map

Source Code:

Special Thanks to:

Sunday, April 29, 2012

Jquery Turn on/off Lights Effect

I found the script to create simple turn on/off lights effect for web pages here:
It use jquery to achieve the effect. The idea is to create a css as the light which covers the page.
However, the original script has several problems:
1. The light can only cover the screen, not the full page.
2. Links and texts are not selectable.
3. Embeded swf will be covered.

The solution to the first problem:
For the second, there is a fix in the comments below there. And the third one, for swf, I defined a new css which will not be covered (higher z-index) and use jquery to change its background to black when turning off the lights.

The final enhanced version:
Source Code
(Scroll down to the bottom of page, click Lights off/Soft lights/Lights on to see the effect, right click to view source.)


Thursday, April 26, 2012

Free SWF Encryptor, Obfuscator and Protectors!

1. Makc3d's open source SWF obfuscator written in AS3 (WTFPLv2):

2. SOB: Open Source SWF Obfuscator.
Can replace the strings in the SWF/ABC string table with random strings.
Source Code (C):

3. Action Script 3 Obfuscator: Python script that takes in a single .as file and makes it hard to decipher.

4. SWF File Obfuscator:
Source Code:

5. SWFLOCK: Online service to do domain lock, trial period and password protection, now free.

6. Flash Protection Gold: Packing, domain locking and can add preloaders for your swf, now free.

7. Flash Free Protection: A free tool that protect your flash files.

8. OBFU: A Flash Action Script obfuscator:
This software is really outdated, but its source code (C, GPL) may be useful. The junk opcodes insertion method is the classical way for cheating decompilers.

9. Actionscript Obfuscator: Flasm based, for AS1,2 only.

10. Actionscript Source Obfuscator:
Obfuscates multiple Actionscript 3.0 source files by remaning all that can be renamed.

11. Flasturbate:
A open source SWF obfuscator based on RABCDAsm.


1. Способы «защиты» flash-приложений
(Ways to «protect» flash-applications, in Russian.
Try Google Translate!)

2. Pack a SWF:

3. Junk instructions insertion method explained:

4. [Tutorial] Applying ROT128 Encryption On Embedded/Module SWFs:

5. [Tutorial] Domain Locking SWFs and Preventing SWFs From Running Locally:
FusionLock – Simple SiteLock AS3 package:

6. Anti-Cheat Methods
Keep the CheateEngine out of your Flash Online Games:
Secure Your SWF Files Against the Cheat Engine:

7. An Introduction to SWF Obfuscation:

8. Advanced protection of Adobe AIR content:

9. More:

Sunday, March 25, 2012

Friday, March 23, 2012

The List of Open Source MineCrafts

MineCraft will be open source someday in the future (
"Once sales start dying and a minimum time has passed, I will release the game source code as some kind of open source. I'm not very happy with the draconian nature of (L)GPL, nor do I believe the other licenses have much merit other than to boost the egos of the original authors, so I might just possibly release it all as public domain. "

But for now, enjoy this list of open source MineCraft alternatives!

1. Manicdigger
"Manic Digger is a public domain 3d block-building game similar to Minecraft."
Features: Infinite world, Rails, Crafting, Shadows, Multiplayer
License: Public Domain
Language: C#

2. Opencraft:
OpenCraft is an alternative Minecraft server, providing more advanced features than the official distribution.
Features: Scripting, griefing preventation
License: BSD
Language: Java

3. Minedroid:
Features: Work with a touchscreen interface
License: New BSD
Language: Java

4. Infiniminer:
Features: multiplayer
License: MIT
Language: C#

5. Minetest-c55:
Features: Survival mode, creative mode, multiplayer, dynamic lighting, almost infinite world, Infinite map generator
License: GPL
Language: C++

6. TechCraft:
Features: Minecraft style terrain engine
License: Ms-PL
Language: C#

7. ArdorCraft:
Features: API to build new types of blockworld games
License: MIT
Language: Java

8. Terasology (Blockmania):
Features: Procedural terrain generation, efficient rendering
License: Apache 2.0
Language: Java

Finally, this one is not open source, but you can't miss it! on voxlap engine)
"It's the best bits of Minecraft crossed with the fast-paced shooter gameplay of Team Fortress."
Features: Dynamic lighting, 32 players battling, CTF or Territory Control game modes
License: Closed Source
Language: C/C++

Ace of Spades is now a commercial game, but we have
9. Iceball: Open Source Version of Ace of Spades!

10. Minecraft in Blender: Minecraft like in the Blender Game Engine.


Crafty (C++)

Craft (C)

Voxel.js (JavaScript, BSD)

Voxeliq (C#)

Blackvoxel (C/C++, GNU GPL V3) 

CraftSaga (Unity, C++)  

AIR-based Minecraft Map Viewer (with source code):

Minecraft like games in flash:

A minecraft level render in flash:
Source Code of MCExplorer (open source minecraft map render/viewer in flash/as3):

Minecraft and WebGL:



Minicraft(update on 2013/11/15, html5 in 252 bytes with source code): (Minecraft in 900 lines of Python)

Others: to Samuel Taylor) (retro-style arcade shooter)

Simple Tutorial for using MochiAds with HaXeNME

HaXeNME ( is an open source, cross platform haxe lib for developing games using a Flash like api. Just try it if you don't know it. If you hope to write once and compile to flash/html5/cpp/ios..., HaXeNME should be your first choice. I never tried to use mochiads with haxenme, though I know it is totally possible. Since some one PMed me for this topic, I did a quick research and want to share it here as a reminder for future reference.

Note: this is not a detailed step-by-step tutorial for newbies, just a reminder. I assume you have some experience of developing with HaXeNME using FlashDevelop ( However, if you have problems, feel free to post it here below.

The general steps for using mochiads with HaXeNME:

1. Download mochi api source code and compile all the AS3 source files into a "mochi.swc", unzip the swc file, rename the "library.swf" to "mochi.swf".

2. Generate the haxe source files needed for compiling your NME project:

haxe.exe -swf mochi.swf --no-output -swf-lib mochi.swf --gen-hx-classes 
Copy the genetated "mochi" folder (in its "as3" subfolder you should find lots of haxe files, such as "MochiAd.hx", "MochiCoins.hx", ...) into your project's "src" folder.

3. Import the mochi apis in your haxe project's main class:
import mochi.as3.MochiAd;
import mochi.as3.MochiServices;
To show pregame ads, for example, using the following code, similar to AS3:
MochiServices.connect("60347b2977273733", root);
MochiAd.showPreGameAd( { id:"60347b2977273733", res:"640x580", clip: root} );

4. Edit your project's "application.nmml", add the following line to force the haxe compiler to link "mochi.swf":
<compilerflag name="-swf-lib yourpath/mochi.swf"/>
Make sure the path to "mochi.swf" is correct.

5. Compile your project, that's all.
(Besides, you can use other swf libs with haxenme similarly.)

Full source code of my test project: MochiAds Test
And the demo swf proving it works: MochiAds Test/bin/flash/bin/HaXeNMEMochiAdsTest.swf 

1. NMML File Format: