Archive for April, 2008

Locking FLA’s under version control

We’ve recently moved over to SVN as our version control system. This system, among other features allows you to request a lock on specific files checked out from the version control system. This means nobody else on your team can check that file in until you have either finished editing and checked it in, or released the lock.

When it comes to FLA files this is great, as unlike actionscript source code, FLA files cannot be automatically merged and so having two people working on the same FLA at the same time creates all kinds of problems, with lost hours, and even lost work.

The problem with optional locking, is that you may not know a file has been locked until you go to check it in, at which point you may have worked on it for hours and so we are presented with the same problem, having to manually merge two versions of the same FLA file.

SVN solves this by allowing you to set the property svn:needs-lock on any file. This means that when a user checks the file out they receive it as read only, and to make it writeable they need to request a lock for the file, at which point their SVN client notifies them that somebody else has the file locked so they need to request that person checks the file in. It also allows you to set auto-props, which are properties to apply to all files of a certain type that are checked into the system. In our case any .FLA files.

This falls down in one respect though. If you are not opening the file from windows explorer (in the case of tortoiseSVN) where you would see the grey icon indicating that a file is read only, but rather from your IDEs recent documents menu, or from a tool that provides a different view to the file system such as FlashDevelop, it relies on whatever tool you use to edit that file telling you that a file is read only. Unfortunately Flash does not warn you when you open a read only FLA. It just opens the “save as” dialog when you try to save the file. This a potential point where you could be facing a file merge, or even worse, lost work.

To get around this I’ve put together a JSFL script that detects when you open a file and examines it’s properties for the read only attribute, then pops up a warning to get a lock from SVN before working on it. Hope people out there find this useful. To use it you need to save it to C:Documents and SettingsusernameLocal SettingsApplication DataAdobeFlash CS3enConfigurationToolscheckReadOnly.jsfl

you can download it here

/**
* Check read only script
* Warns you about opening read only files in Flash IDE
* By Phil Douglas 2008
* www.lookmumimontheinternet.com
**/
fl.outputPanel.clear();
trace = fl.outputPanel.trace;
function onDocumentOpened(){
var currentDoc = fl.getDocumentDOM();
nativePath = currentDoc.path;
uriPath = nativePath.split(':').join('|');
uriPath = uriPath.split("").join("/");
uriPath = 'file:///'+uriPath
attributes = FLfile.getAttributes(uriPath)
if(attributes.indexOf('R')!=-1){
alert('This file is read only. If it is in SVN you should request a lock before working on it.');
}
}
fl.removeEventListener("documentOpened", onDocumentOpened);
fl.addEventListener("documentOpened", onDocumentOpened);

3 Comments



  • SetPageWidth