简体   繁体   English

AS3 Flash SWF文件版本控制

[英]AS3 Flash SWF File Versioning

I've looked all over online and can't seem to find a way to put a version number in a swf file. 我在网上看了遍,似乎找不到找到在SWF文件中放入版本号的方法。 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. 我们需要知道在不同机器上拥有的swf文件的版本,因此我们考虑过,如果文件不存在到swf目录中,则可能会写入该文件,其中包含swf版本号。 We are not using Flex and as3, so that's not going to work since we can't write to the disk. 我们没有使用Flex和as3,因此无法工作,因为我们无法写入磁盘。 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". 因此,我一直在四处查看,却找不到我们可以将swf的文件版本指定为“ 14.06.30”之类的位置。

Is there a way we might be able to set the version of our swf file? 有什么方法可以设置SWF文件的版本?

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. 我们已经考虑过使用按键来显示版本号,但是我们不想这样做,因为swf可以加载到其他swf中,而按键可能意味着其他含义。 This would be a last resort. 这将是不得已的方法。

For version numbering in the swf, we use a compile constant http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7abd.html . 对于swf中的版本编号,我们使用一个编译常量http://help.adobe.com/zh_CN/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. 例如:-define + == CONFIG :: VersionString,'{svn版本}'使用Flash Builder,您可以将其添加到其他编译器设置中,或在Continuous build脚本中设置此变量。 In your actionscript you can read this var with 'CONFIG::VersionString'. 在您的动作脚本中,您可以使用'CONFIG :: VersionString'读取此变量。

We add this version number to the context menu in the swf (right click menu). 我们将此版本号添加到swf(右键单击菜单)的上下文菜单中。

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: 如果右键单击瑞士法郎,它看起来像:

在此处输入图片说明

You can use a SharedObject to store and retrieve the version number: 您可以使用SharedObject来存储和检索版本号:

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. 如果您有SharedObject阅读器(建议使用.minerva ),则无需打开swf即可检索设置值。 Just open the .sol file. 只需打开.sol文件。

For SWFs, .sol files are stored in C:\\Users\\[USER-NAME]\\AppData\\Roaming\\Macromedia\\Flash Player\\#SharedObjects\\[random sequence of characters] 对于SWF, .sol文件存储在C:\\Users\\[USER-NAME]\\AppData\\Roaming\\Macromedia\\Flash Player\\#SharedObjects\\[random sequence of characters]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM