Do you like my tutorials?

Then consider supporting me on Ko-fi

Talking about Flash.

Do you know what is Adobe Alchemy?

Alchemy allows programmers to compile C and C++ scripts into SWC files to make them run on Adobe Flash Player 10 or Adobe AIR 1.5. In other words, you can compile the hundreds of millions of lines of existing open source C and C++ project to use them in Flash.

Some examples of existing C libraries compiled with Alchemy are Doom Triple Pack and World Construction Kit. And it’s free!!

The other side of the coin is still in beta (Adobe calls it “prerelease software”), not supported by Adobe, and not that user friendly.

That’s why I am writing this guide to have Alchemy running on your Mac. I’m starting with a Mac because if you find this guide difficult, be prepared… Windows installation is even worse. Anyway, let’s start:

Download everything you need

Before you start playing with Alchemy, there are some free softwares to download.

Xcode. It’s the developer tool for for Mac OSX and you will need to register to download it. Simply install it following the instruction it will give you.

Alchemy Toolkit for Mac OSX, that’s Alchemy itself. Unzip the entire folder in the root directory of your hard drive. Usually it’s called Macintosh HD.

Adobe Flex SDK, used to produce the final SWC. I wouldn’t use Nightly Builds. Unzip this package in the root directory of your hard drive, just like you made with Alchemy.

Also try to call the folders in a way easy to remember, such as flex and alchemy. This is how should it be your download window:

And this is what you should see in your finder:

Using Terminal

I told you it wasn’t user friendly… so we have to open Terminal and enter some text commands.

“Open” alchemy folder…

cd /alchemy/

and execute config file

./config

You should see something like this:

Generating alchemy-setup...
Turning execution bit on for Alchemy binaries...

Add "source /alchemy/alchemy-setup" to your login script.
"alc-home" takes you to the Alchemy install folder.
"alc-on" puts Alchemy gcc toolchain replacements at the front of your path.
"alc-off" restores original path.
"alc-util" shows you various Alchemy-related environment vars
You need Flash 10 or AIR 1.5 and the Flex 3.2 SDK installed for testing.

Don’t worry if you get a warning like this:

WARNING: "adl" not available
To correct this warning, install the Flex SDK 3.2+ and add /path/to/FlexSDK/bin to your path.

as it will be corrected later.

Now edit adl file in your flex/bin folder. Find this line:

#export ADL=/path/to/your/adl (or adl.exe)

and assuming your Flex folder is called flex, change with:

export ADL=/flex/bin/adl

Return to Terminal and enter the following commands, assuming you are using flex and alchemy folder names:

export FLEX_HOME=/flex/bin
export ALCHEMY_HOME=/alchemy
source /alchemy/alchemy-setup 
PATH=$ALCHEMY_HOME/achacks:/flex/bin:$PATH
export PATH

Finally turn on alchemy:

alc-on

Enter in a folder with an example source code:

cd /alchemy/samples/stringecho/

and compile the C source code into an SWC:

gcc stringecho.c -O3 -Wall -swc -o stringecho_triqui.swc

You should see something like this:

WARNING: While resolving call to function 'main' arguments were dropped!

1756.achacks.swf, 260699 bytes written
frame rate: 60
frame count: 1
69 : 4
72 : 260622
76 : 40
1 : 0
0 : 0
frame rate: 24
frame count: 1
69 : 4
77 : 506
64 : 31
63 : 16
65 : 4
9 : 3
41 : 26
82 : 471
1 : 0
0 : 0
adding: catalog.xml (deflated 75%)
adding: library.swf (deflated 70%)

And you should see a file called stringecho_triqui.swc in your stringecho folder, like in this picture:

Congratulations! You just compiled your first C code into a SWC with Alchemy.

Next time, I’ll show you what to do with it.

Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.