我如何code在ActionScript几个SWF我已经包括了我的apk的确切文件位置?我的、几个、确切、我已经

2023-09-08 14:24:46 作者:我是女王欧买噶!

在空中为Android设置的包含文件的一部分,我加入t​​est1.swf和test2.swf自动包含主文件。请问以下是正确的话:

  myLoader.load(新的URLRequest(test1.swf)
 

或者说,有没有其他的文件夹,我应该包括哪些内容?请问下是正确的?

  myLoader.load(新的URLRequest(\ .. \ .. test1.swf)
 
actionscript –

解决方案

我不是在一个位置上的Andr​​oid现在来测试这个权利,但我相信包括的文件放在应用程序目录,您可以访问如下

  VAR路径:字符串= File.applicationDirectory.resolvePath(test1.swf)nativePath的。

myLoader.load(新的URLRequest(路径));
 

您还可以使用速记网址:

  myLoader.load(新的URLRequest(应用程序://test1.swf));
 

您也可以加载使用的FileStream 类,它给你更好地控制事物的SWF。这将是这样的:

  var文件:文件= File.applicationDirectory.resolvePath(test1.swf);

    如果(file.exists){
        VAR swfData:ByteArray的=新的ByteArray();
        VAR流:的FileStream =新的FileStream();
        stream.open(文件,FileMode.READ);
        stream.readBytes(sw​​fData);
        stream.close();

        VAR myLoader:装载机=新的Loader();
        VAR的LoaderContext:的LoaderContext =的新LoaderContext(假,ApplicationDomain.currentDomain来);
        loaderContext.allow codeImport = TRUE;

        myLoader.loadBytes(sw​​fData,的LoaderContext);
        的addChild(myLoader);

    }其他 {
        跟踪(文件不存在);
    }
 

In Air for Android Setting's 'Include files' part, I added test1.swf and test2.swf to the main file automatically included. Would the following be correct then:

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

Or, is there any other folder I should include? Would the following be correct?

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

解决方案

I'm not in a position to test this right now on Android, but I believe included files are put in the application directory, which you can access as follows:

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

myLoader.load(new URLRequest(path));

You can also use the shorthand url of:

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

You could also load the swf with the FileStream class, which gives you more control over things. That would look like this:

    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");
    }