How to use FlashDevelop to code for Stencyl
This post will show you what are the steps needed to use FlashDevelop to code your behaviors.
We will
NOT simply use FlashDevelop to edit the behavior files, we will have all the advantages of using a proper IDE, and that means proper code completion and hints (Intellisense), code generation,
debugging, compiling, and of course syntax highlighting.
What we assume- This guide assumes FlashDevelop and haxe are not installed.
- This guide assumes the use of a Windows based OS
- This guide assumes that the user can change the system path without problems
- This guide assumes that a new blank game will be used to test things
- This guide assumes the user will use the correct paths if he uses this guide
- This guide assumes that the user can find the games-generated folder
- This guide assumes that if any of the above will fail, then the user will not read any further
What do we need to do ?First install FlashDevelop, but do
NOT install any package when you're presented with a window to install additional content.
When the installation completes close FlashDevelop, because we need to add 2 locations to the system path:
D:\Program Files (x86)
\Stencyl\plaf\neko-win\ and D:\Program Files (x86)
\Stencyl\plaf\haxe\ Replace with the correct path for your systemCreate a new game (I named mine
design), with a scene and a
code mode scene behavior (make sure the behavior is attached to the scene) and
TEST THAT GAME inside Stencyl. Testing the game will create the necessary directory structure in the games-generated folder, and so there is no need to actually add something in the behavior created above. Do remember the name of the game as it will be needed in the next step.
Setup FlashDevelopOpen FlashDevelop and create a new Project. In the New Project window you must pick an
Empty haxe Project, and for the name you must type the name of the game you created in Stencyl. The Location
MUST point at the games-generated folder.
After you press ok you'll get a warning that you can ignore
(something's actually wrong if you don't get that warning), and in the side view you should see the entire directory structure that Stencyl created when we tested the game.
Let's tell FlashDevelop where haxe is installedIn Flashdevelop go to
Project ->
SDK ->
Manage In the window that pops up open
InstalledSDK[] Array and you should get the following window where you must add the path to the haxe folder:
The
Name and
Version do not matter so use whatever you want for those.
I restarted FlashDevelop after this step.
Back to FlashDevelopLet's continue to setup FlashDevelop to make it recognize all the classes available in Stencyl, so let's go back to the Project Properties:
- In the
Output tab select
Lime as the Platform and
project.xml in the Output field:
Don't worry about the Dimensions, color and framerate. They will get set automatically - In the
Classpath tab click on
Edit Global Classpaths... and from there click on
Add Classpath. Locate the following folder and add it in the path:
At this point I restarted Flashdevelop again and now we can compile the game from within Flashdevelop:
but... Almost thereWe're currently working in the
games-generated folder, so any file that we edit now (located in
Source ->
scripts)will be deleted the next time we test the game from within Stencyl.
To fix that, we will copy all the files from the
scripts folder back into the
games folder. To do that we must create a text file that will be placed in the
C:\ drive. So create a text file, name it
exclude.txt and paste the following inside it:
Design
SceneEvents_0
MyAssets
MyScripts
StencylPreloader
And for the last time (for this project) we need to go back into the Project Properties into the
Build tab and add the following into the
Post-Build Command Line:
c:\windows\system32\cmd.exe /C copy "$(ProjectDir)\Source\scripts\Design*.hx" "$(ProjectDir)\..\..\games\$(ProjectName)\snippets\"
c:\windows\system32\cmd.exe /C xcopy "$(ProjectDir)\Source\scripts\*.hx" "$(ProjectDir)\..\..\games\$(ProjectName)\code\" /Y /exclude:c:\exclude.txt
From now on you can add code and compile the game without the need to have Stencyl opened.
The Problems: - You must follow this tutorial for every game you want to work on.
- The change to any design mode behavior will not be permanent or it will not work. Only work on code mode behaviors.
- Any new class that you wish to attach to a scene or actor must be created in Stencyl and the game must be tested in Stencyl first.
- After the creation of a new Scene you must test the game in Stencyl.
Contributors:This was possible thanks to the following contributors :
-
Hectate -
Justin -
MdotEdot