0
votes

I've looked all over online and can't seem to find a way to put a version number in a swf file. We need to know which version of the swf file we have on different machines, so we had thought of maybe writing a file if it does not exist to the swf directory, containing the swf version number. We are not using Flex and as3, so that's not going to work since we can't write to the disk. So i've been looking around and haven't been able to find where we might specify the file version of our swf to something like "14.06.30".

Is there a way we might be able to set the version of our swf file?

We've thought about using a key press to display a version number, but we don't want to do that because the swf can load in other swf's where keypresses might mean something else. This would be a last resort.

2
Couldn't you just add meta data on the file itself? - BadFeelingAboutThis
Also, unless you're stopping propagation of the event, you can have multiple keyboard event listeners that run together. - BadFeelingAboutThis
@LDMediaServices your right, that was actually what i was looking for in the first place. We got it covered though using the context menu, which will work just as well, possibly even better since they don't have to find the swf file or close it if its running - iedoc

2 Answers

6
votes

For version numbering in the swf, we use a compile constant http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7abd.html. For example: -define+==CONFIG::VersionString,'{svn version}' With Flash builder you can add this to your additional compiler settings, or set this variable in your Continuous build script. In your actionscript you can read this var with 'CONFIG::VersionString'.

We add this version number to the context menu in the swf (right click menu).

package {
import flash.display.Sprite;

public class Test extends Sprite
{
    public function Test()
    {
        super();
        addVersionToContextMenu();

    }

    private function addVersionToContextMenu () : void
    {
        var item:ContextMenuItem = new ContextMenuItem("Version: " + CONFIG::VersionString);
        var items:Array = this.contextMenu.customItems;
        items.push(item);
        this.contextMenu.customItems = items;
    }
}

}

If you right click on the swf it looks like:

enter image description here

1
votes

You can use a SharedObject to store and retrieve the version number:

var sharedObject:SharedObject = SharedObject.getLocal("versionNumber");
var versionNumber:String;
if(sharedObject.data.value)
{
    versionNumber = sharedObject.data.value;
}
else 
{
    // no version number has been set, set it here
    versionNumber = "14.06.30";
    sharedObject.data.value = versionNumber
    sharedObject.flush();
}

If you have a SharedObject reader (I recommend .minerva) You can retrieve the set value without even opening the swf. Just open the .sol file.

For SWFs, .sol files are stored in C:\Users\[USER-NAME]\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\[random sequence of characters]