我如何在 actionscript 中为我的 apk 包含的几个 swf 的确切文件位置编写代码?

How do I code in actionscript the exact file location for several swf I have included for my apk?

在 Android 设置的 'Include files' 部分的 Air 中,我将 test1.swf 和 test2.swf 添加到自动包含的主文件中。那么以下是否正确:

myLoader.load(new URLRequest("test1.swf")

或者,是否还有其他我应该包含的文件夹?以下是正确的吗?

myLoader.load(new URLRequest("\..\..test1.swf")

我现在无法在 Android 上对此进行测试,但我相信包含的文件已放在应用程序目录中,您可以按如下方式访问该目录:

var path:String = File.applicationDirectory.resolvePath("test1.swf").nativePath;

myLoader.load(new URLRequest(path));

您还可以使用 shorthand url of:

myLoader.load(new URLRequest("app://test1.swf"));

您还可以使用 FileStream class 加载 swf,这样您可以更好地控制事物。看起来像这样:

    var file:File = File.applicationDirectory.resolvePath("test1.swf");

    if (file.exists) {
        var swfData:ByteArray = new ByteArray();
        var stream:FileStream = new FileStream();
        stream.open(file, FileMode.READ);
        stream.readBytes(swfData);
        stream.close();

        var myLoader:Loader = new Loader();
        var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
        loaderContext.allowCodeImport = true;

        myLoader.loadBytes(swfData, loaderContext);
        addChild(myLoader);

    }else {
        trace("file doesn't exist");
    }