Flash/Flex: Integrating subversion revision into exe/swf file?

I recently I followed this great guide to integrate the subversion revision into exe/dll files generated from my c++/c# visual studio projects. Now I can easily right-click on an exe-file to find which revision was used to build the binary (see image below). I love this feature.

Is this possible to do the same in flash/flex when building air/stand-alone applications? I would like to tag both exe file and dlls.

Flash/Flex: Integrating subversion revision into exe/swf file?



Update with solution:

Although the ANT-based solutions provided here aren't as smooth as the one where the svn info is burnt into .exe/.dll files (in my opinion), it has solved my problem and is now implemented in our productions. My setup is based both on Kevin's and frankhermes's answeres but uses SubMCRev.exe instead of svn.exe or jar files.

In our implementation we dump the svn revision to the logfile at startup. The output from the SVN target below looks like this:

Built with SVN Revision: 1.0.0.1181 (local modifications found)

SVN target:

<target name="SVN Revision"> <exec executable="subWCRev.exe" outputproperty="revision"> <arg value="${basedir}\\.." /> <redirector> <outputfilterchain> <linecontainsregexp> <regexp pattern='^([Last]|[Local])' /> </linecontainsregexp> <tokenfilter> <replaceregex pattern='[\D]+([\d]+)' replace="Built with SVN Revision: 1.0.0.\1" /> <replaceregex pattern='Local modifications found' replace=" (local modifications found)" /> </tokenfilter> <striplinebreaks /> </outputfilterchain> </redirector> </exec> </target>

Compile target:

<target name="compile" depends="init, SVN Revision"> <mxmlc file="..." output="..."> <define name="compile::REVISION" value="'${revision}'" /> .... </mxmlc> </target>

-------------Problems Reply------------

We use the following method (and it's pretty similar to Kevin's answer but I can confirm that it works):

a snippet from my build.xml: this uses two jar files (svnkit and svntask) instead of svn.exe (so it runs cross-platform) - these jars are checked in via svn too so you can't lose them or misinstall.

<!-- SVN revision stuff -->
<typedef resource="com/googlecode/svntask/svntask.xml">
<classpath>
<fileset dir="${basedir}/util">
<include name="svnkit.jar"/>
<include name="svntask.jar"/>
</fileset>
</classpath>
</typedef>

<target name="revision">
<svn><info path="${basedir}" revisionProperty="revision" /></svn>
<echo>${revision}</echo>
</target>
<!-- /SVN revision stuff -->

Now we have the revision in a property that we include in the mxmlc task as a conditional compiler variable:

<mxmlc file="${src.dir}/@{appfile}[email protected]{ext}"
output="@{output}/@{appfile}.swf"
debug="@{debug}"
target-player="${version_major}"
optimize="true"
locale=""
use-network="true"
>
<define name="compile::REVISION" value="'${revision}'"/>
[... rest snipped]
</mxmlc>

Then you can use that variable in AS:

var version:String = "1.0."+compile::REVISION;

For the code to work in Flash Builder too, you'd have to add the following line to your additional compiler arguments:

-define+=compile::REVISION,'dev'

That way your development code will have the revision 'dev', indicating that it was not necessarily built from a committed version of the code.

I was actually looking to do this myself, so I figured I'd investigate it. I use ANT and mxmlc to do my builds. Here is an ANT snippet I found here to get the revision number:.

<target name="find_revision" description="Sets property 'revision.number' to the head svn revision">
<property name="revision" value="HEAD"/>

<!-- find out revision number of HEAD, need svn.exe installed on local machine -->
<exec executable="svn" outputproperty="revision.number">
<arg line="info -r ${revision}"/>
<redirector>
<outputfilterchain>
<linecontainsregexp>
<regexp pattern='^Revision' />
</linecontainsregexp>
<tokenfilter>
<replaceregex pattern='[\D]+([\d]+)' replace="\1" />
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
</target>

With the revision number found one could pass the variable as a global constant at compilation time. This is accomplished via the mxmlc parameter:.

define=NAMESPACE::variable,value

This variable can be retrieved in AS3 and used in whatever way you want. See using conditional compilation for details.

I haven't found a way to set an AIR Application's descriptors programmatically yet, so you might have to edit/create your XML descriptor file via ANT before compilation.

Let me know if this method works for you so I can use it myself =D

Category:flash Views:1 Time:2011-04-15

Related post

  • Flex ant build - how to reduce swf file size 2011-02-07

    When I build flex project using ant, the resultant .SWF file size is 329 KB. The same project exports .SWF file using flex builder, the size of .SWF file is 108 KB. In flex builder, I am using .SWC library in library path and RSL as framework linkage

  • Can I pass parameters in Flex 3 to variables in a swf file using swfloader? 2011-04-28

    I've created a Flash Animation (CS5, ActionScript 3) and converted it to SWF. The flash animation needs the values of 3 variables (defined in the swf timeline) BEFORE it starts running in my Flex application. I've embedded the swf file using swfloade

  • flash player 11 - can't play local swf files 2011-11-30

    in older versions of flash player if I opened a swf file in a web page locally it would bring up a security settings box where I could allow files to play locally - but this doesn't seem to happen in flash player 11 - how do I enable my swfs to play

  • FLASH AS3 - How to stop an external swf file 2011-11-04

    I have this homepage, http://www.friedmanllp.com/home3.php, and two separate .swf files. I want the top .swf, the skip bar, to stop the bottom video. Is there anyway to do this? Note I have no way to edit the original video. I wouldn't mind using a j

  • Is playerglobal.swc the only dependency of the Flex SDK needed to build a swf file? 2011-07-15

    I am trying out FDT and it has several bundled SDKs. Some of them are labeled pure and only contain the playerglobal.swc. Is this to compile ActionScript 3 only swfs? --------------Solutions------------- Yes. Also keep in mind that AS3 Project Types

  • Can I call an external script or program when building a SWF file in Flash CS3? 2008-09-17

    Is there a way to call an external script or program from Flash CS3 every time it builds a SWF file? I'd like to add subversion information using subwcrev - the SVN keywords don't work because they only update when the version class file is updated.

  • Flash SWF file cannot find XML data file when loaded into WebBrowser control (but works in IE9) 2011-09-22

    Bit of a long explanation below, with a hopefully accurate short question summary here: Can a .NET WebBrowser control (Win7 64-bit, IE9, current Flash 10.3.183.7) load a SWF file into an <object> tag, where the SWF file is in a separate folder

  • Actionscript 3.0 Loading swf file into flash project 2010-11-18

    http://tinypic.com/r/9i8hi0/7 It's a video showing you my problem. I don't know why the swf file won't work in the flash I used loader to put the swf file into the stage but it doesn't do it. I plays fine when I just open the swf file in Flash Pro CS

  • Security issue in regard to flash .swf files 2011-12-29

    I allow people to upload .swf file (games) to my server. I review them, and post the good ones on the site. Can somehow, theoretically, put a pure flash uploader script into the game, and upload malicious files to the server? All the flash upload scr

  • Loading external .swf file in Air application causing looping constructor 2011-04-19

    I've never encountered this problem before, it seems really bizarre. I'm building an Air application (straight AS3 no flex) that embeds and displays a .swf file. Here is my code: public class Something extends Sprite { private var loader:Loader; publ

  • Loading and using SWF files 2012-03-25

    I'm new to AS3, and am trying to understand how externally loaded SWFs work in AS3. Since Flash 4/5, it was common to have one main SWF file in a Flash web project, and then load other SWF files into it, often for various "sections" of a website or w

  • How to run an EXE file from Flash/Flex/AIR? 2010-10-29

    I want to run an .exe file from my Flash/Flex/AIR Application, How is it possible? What I need is to build an Interface to open a xls file and convert it into swf, I have the converter file which is an exe file, when I run convert.exe infile.xls outF

  • Convert Multiple SWF files to Single EXE 2010-11-22

    Hi I have an application in flash, I build in ActionScript 3.0 Flash IDE, my application loads some external swfs which mentioned via XML file. Its working fine at the moment. But I need to compile all these external SWFs and xml file into single exe

  • How do I unload a externally loaded SWF file from a SWFLoader component in Adobe Flex? 2008-09-22

    I have an application that loads external SWF files and plays them inside a Adobe Flex / Air application via the SWFLoader Flex component. I have been trying to find a way to unload them from a button click event. I have Google'd far and wide and no

  • Different framerate for loaded SWF file in Flex? 2008-09-23

    Using The loader class of Adobe Flex, I load an external SWF file. However, the loaded SWF file has a different frameRate than my application. Is it possible to have both the parent app and the loaded child app playing at different framerates? If so,

  • Does anyone know of a php framework that would handle progressive enhancement for Flash/Flex content? 2008-10-03

    Ok, I'm using the term "Progressive Enhancement" kind of loosely here but basically I have a Flash-based website that supports deep linking and loads content dynamically - what I'd like to do is provide alternate content (text) for those either not h

  • Image loading icon for flash/flex? 2008-11-07

    You often see those little 'petal' animations while an image or .swf file is loading in a Flash / Flex application. Do I have to steal this from someone or is there a standard one available from somewhere. i would think there is somethin standard bec

  • Need to set cookie header on AIR use of SWFLoader to retrieve remote Flex .swf file 2009-03-24

    Am coding an AIR 1.5 app in which I want to do a remote load of a Flex .swf file from a web server. I'm using Flex 3.2 SDK and attempting to use the sub-application feature via SWFLoader. I've been referencing the Developing and loading sub-applicati

  • How to synchronize SVN revision and version ressources of EXE/DLL files? 2009-04-25

    Say I have some C++ project which builds an exe or dll file. The project is checked into a SVN repository. I want to automatically synchronize the revision from SVN with the version resource embedded in my exe/dll file, i.e. the version should be som

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.075 (s). 11 q(s)