SVN version control in Flashdevelop projects
A couple of applications that really have helped my work flow a lot is Flashdevelop and TortoiseSVN.
For those of you not familiar with them Flashdevelop is an actionscript editor that integrates with MTASC or MXMLC compilers and swfmill to include assets into the project.
TortoiseSVN is a version control system which basically is a must on large projects and very handy even on smaller projects even if you are developing alone and just keep the repository on your local machine. TortoiseSVN also comes with a program called SubWCRev which we will use to write information about the current version into a textfile, which is handy so we can load it into our swf to display the current version.
First of all you need to download and install the applications if you don't have them already.
Get Flashdevelop
Get TortoiseSVN
First step is to set up your "repository" and "working copy" directories.
I will not explain that part here since there is already many good guides on that subject, for example this pfd.
It is a little bit of an effort initially but I can assure you it's energy well spent.
Now in Flashdevelop select Project->New Project in the menu to create a new AS2 or AS3 project in your working copy directory.
For example say we have created a working copy folder called "E:\_dev\Example", you settings will look like this in the new project dialogue:

Ok, so now we are all set up to actually integrate the SVN with our Flashdevelop project.
First of all create a new text file in your working directory and name it "build.bat".
In it enter the following:
@ECHO OFF
set TORTOISESVN_PATH=C:\Program Files\TortoiseSVN\bin
set CURRENT_PATH=%CD%"%TORTOISESVN_PATH%\TortoiseProc.exe" /command:commit /path:"%CURRENT_PATH%\*"/logmsgfile:"%CURRENT_PATH%\logmsg.txt" /notempfile /closeonend:3
"%TORTOISESVN_PATH%\SubWCRev.exe" "%CURRENT_PATH%" "%CURRENT_PATH%\version.a" "%CURRENT_PATH%\version.txt"
pause
Make sure that the "TORTOISESVN_PATH" is the same as the one you have installed TortoiseSVN to and save.
Basically what this batch file is doing is first to call TortoiseSVN telling it to commit changes and then calling SubWCRev to take the template for our version text (version.a) and use that to write a file that we will load into our app for displaying the version information (version.txt).
So we need to create a file called version.a containing the following text:
major=0; minor=1; build=$WCREV$ ; date="$WCDATE$" ;
The stuff between the $'s is what will be substituted by SubWCRev.
Here is a complete list of substitution keywords if you like to include more information, but usually the build number is all that I would use.
The major and minor version numbers one have to update by hand, at least to my knowledge.
Now in Flashdevelop go Project->Properties and open the "Build" tab.
In the "Post-Build Command Line" type: $(ProjectDir)\build.bat:

Now you are set up and each time you build in Flashdevelop you will get presented with a screen where you can enter a log message for the change if you like to commit it, or you can choose cancel and the change will not be committed.
If you like to have a default log message for the commit add a logmsg.txt in the working copy directory with the text you like to appear.
If you like to display the version information in your swf you have to load the version.txt and display the information. Here is an AS3 example:
package com.blixtsystems.utils {
import flash.events.Event;
import flash.events.IEventDispatcher;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
/**
* Class to display version information
* @author leo@blixtsystems.com
*/
public class ShowVersion {
private var _owner:Object;
public function ShowVersion(owner:Object) {
this._owner = owner;
loadTxt();
}
private function loadTxt():void {
var loader:URLLoader = new URLLoader();
configureListeners(loader);
var request:URLRequest = new URLRequest("version.txt");
try {
loader.load(request);
} catch (error:Error) {
trace("Unable to load version.txt.");
}
}
private function configureListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
}
private function completeHandler(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
this.draw(loader.data);
}
private function draw(data:Object):void {
var a:Array = data.split(";");
var major:String = a[0].split("=")[1];
var minor:String = a[1].split("=")[1];
var build:String = a[2].split("=")[1];
var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.color = 0x000000;
format.size = 10;
tf.defaultTextFormat = format;
tf.text = major + "." + minor + "." + build;
this._owner.addChild(tf);
}
}
}
That's it, now every time you press F8 in Flashdevelop you will add any altered files to the repository and your swf will reflect the current version number!




Trying it out now…
What exactly is \version.a ?
thanks…
The “version.a” is simply a text file.
So just create a new text file, name it “version.a” and open it in for example notepad, then paste the the text into it as described in the article and save it.
The “.a” extension is just to separate it from the “version.txt” which is the output file that we will read into the swf to display version information. You can call the file what you like as long as the name is the same in your “build.bat”.
Brilliant! Thank you so much for the information. I’m finally integrating version control into my work flow–your tutorial makes my life so much easier!!
This is great!
Using the build.bat file (which works a treat) prevents Flash from publishing the open FLA, and I generally use FlashDevelop with AS3 IDE projects.
is there anyway to modify the build.bat file so it tacks on this behaviour afterwards?
So when I hit F8 in FlashDevelop, build.bat is fired allowing me to commit my changes to the SVN AND then Flash publishes my currently open FLA.
Hi Gavin,
I’m afraid I have not used IDE projects for quite some time, so I’m not familiar with the issue.
I would have thought it would work the same with IDE projects…otherwise I guess one could try to make it a pre-build command instead in the project settings.
There is obviously a lot to know about this. I think you made some good points in Features also.
boris is a slimy bot ffs
gr8 work bro, check out my blog when you have the time, don’t forget~
Very great article !!! Thanks
I’ve inserted version.a and build.dat in the all the templates of FD (C:\Program Files\FlashDevelop\Projects\) to obtain it automaticaly when you makes a new proyect.
bye.
thanx for the how to. I am having a minor issue. Everything seems to work but when I add $(ProjectDir)\build.bat to build it no longer compiles in flash or at all. the subversion and tortiusesvn work I get the windows poping up but then it never goes to flash to compile and test. Am I missing something?
Great post! Can’t live without SVN. Flash Develop is probably the main AS tools I use. However, I am looking into Flash Builder now and see how that workflow goes.
Thx!
David
In order to get it working I added double quotes:
“$(ProjectDir)\build.bat”
I am running flashdevelop standalone on a stick.
Hey thanks for this, svn is great
Can we add a button to flash develop for this, that cant be hard right.
Whats the pause in the bat for? I was having the same problem as dave had, it does as it says pauses??
Hi
thanks for this gem! The bat file wouldn’t run the commit for me (running xp?) so I modified it to the following which works perfectly.
@ECHO OFF
set TORTOISESVN_PATH = C:\Program Files\TortoiseSVN\bin
set CURRENT_PATH=?%
CD %TORTOISESVN_PATH%
start TortoiseProc.exe /command:commit /path:”%CURRENT_PATH%\*” /logmsgfile:”%CURRENT_PATH%\logmsg.txt” /notempfile /closeonend:3
start SubWCRev.exe %CURRENT_PATH% “%CURRENT_PATH%\version.a” “%CURRENT_PATH%\version.txt”
pause
Hi,
pretty cool stuff. I’m trying it out now. I have a little issue though. If I compile the first time it works as expected. But if I try the second time, flash-develop keeps saying:
“A process is currently running.” It does not stop. I can’t recompile. This is because the “build started” but was never finished. The .swf does not show. Like Dave and Chris above.
However if I goto Tools > Kill Running Process, the “build started” disappears but the Error “A process is currently running.” remains when retrying. I Tried Nicholas’ suggestion since I’m on XP but this gives an incorrect filepath to Tortoise.
Now after removing the ‘pause’ in build.bat it seems to work. Except for the version.txt not being commited to the rep.
So basically I, like Chris, wonder what the pause is for or rather how the process can be restarted after having done what it needed to be paused for ? Can it be replaced by something like a timeout, or delay ?
Any clues ? I ‘ll post here if I find any..