actionscript-3 - AS3 库不兼容

标签 actionscript-3 namespaces swc smartfoxserver

背景:

我正在编写一个 Flash 游戏并且遇到了一个问题。
我一直在使用 Polygonal 的 AS3 数据结构 ( http://code.google.com/p/polygonal/wiki/DataStructures ) 没有任何问题。

我最近为游戏添加了 SmartFoxServer 2X 支持 ( http://www.smartfoxserver.com/ )。一旦我导入 SmartFox SWC 文件,我就会收到“new LinkedQueue()”调用的运行时错误,表明覆盖不兼容。

无论如何,我向 Polygonal 提交了一个错误,结果发现 SmartFox 使用的是他的数据结构的旧版本,并将其包含在他们的 SWC 文件中。

我的问题:

考虑到我只有两个 SWC 文件,有什么方法可以强制将它们放入不同的命名空间?这将允许我将新版本与 smartfox 的旧版本一起使用。

最佳答案

是的,如果真的很重要,又想花时间,可以通过更改里面的swf和catalog来修改swc里面的package。

这是一个使用 SWFWire Decompiler 的示例 AIR 项目:

public class SWFWireCompiler extends Sprite
{
    public function SWCEditor()
    {
        stage.nativeWindow.activate();

        var bytes:ByteArray = getBytes('library.swf');

        var swfReader:SWFReader = new SWF10Reader();
        var readResult:SWFReadResult = swfReader.read(new SWFByteArray(bytes));
        readResult.swf.header.signature = SWFHeader.UNCOMPRESSED_SIGNATURE;

        for each(var tag:SWFTag in readResult.swf.tags)
        {
            var abcTag:DoABCTag = tag as DoABCTag;
            if(abcTag)
            {
                for each(var string:StringToken in abcTag.abcFile.cpool.strings)
                {
                    if(string.utf8 == 'de.polygonal.ds')
                    {
                        string.utf8 = 'de.polygonal.ds.old';
                    }
                }
            }
        }

        var swfWriter:SWFWriter = new SWF10Writer();
        var writeResult:SWFWriteResult = swfWriter.write(readResult.swf);

        writeBytes('C:\\output.swf', writeResult.bytes);
    }

    private function getBytes(file:String):ByteArray
    {
        var bytes:ByteArray = new ByteArray();
        var stream:FileStream = new FileStream();
        stream.open(File.applicationDirectory.resolvePath(file), FileMode.READ);
        stream.readBytes(bytes);
        stream.close();
        return bytes;
    }

    private function writeBytes(filename:String, bytes:ByteArray):void
    {
        var file:File = new File(filename);
        var fs:FileStream = new FileStream();
        fs.open(file, FileMode.WRITE);
        fs.writeBytes(bytes);
        fs.close();
    }
}

然后,您必须在 catalog.xml 中进行查找/替换,然后重新打包它。

关于actionscript-3 - AS3 库不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5190100/

相关文章:

actionscript-3 - 在 Flash 网站上添加元数据

actionscript-3 - 循环声音闪烁as3

apache-flex - 在多个 Flex 应用程序之间共享 Assets (图标/图像)的最佳方式是什么?

c# - 如何在 C# 中定义 "anonymous namespace"?

php - 在层次结构目录结构中使用 PHP 命名空间错误

flash - 使用 ActionScript 3.0 + Flash/Flex 链接 SWC 的运行时自省(introspection)

apache-flex - 找出 *.SWC 文件的包名称,以便我可以导入它

arrays - 为什么 AS3 在 for 循环中创建新实例?

ios - cacheAsBitmap 对 AIR for iOS 中使用 scrollRect mask 的 Sprite 没有影响

php - PHP 5.3 中接口(interface)/抽象类的命名(使用命名空间)