Skip to content Skip to sidebar Skip to footer

How Do I Code In Actionscript The Exact File Location For Several Swf I Have Included For My Apk?

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

Solution 1:

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

Post a Comment for "How Do I Code In Actionscript The Exact File Location For Several Swf I Have Included For My Apk?"