Air for android ignores external swf files

2019-03-03 16:41发布

I am working on some app that loads external swfs from the application directory the problem is that some swf files get loaded correctly and others give ioerror url not found

i put the paths in an array and use a loader to load the path

var arr:Array = ["Games/1.swf", "Games/2.swf"];
var loader:Loader = new Loader();
loader.load(new URLRequest(arr[0]));

this is just example and it is the same in loading all the files but does not work on all files. what would be the problem?

1条回答
劳资没心,怎么记你
2楼-- · 2019-03-03 16:58

Firstly, whenever you load something, listen for the appropriate error events so you know what's going on:

loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

When using mobile, you should use the app:// shorthand as a reference to the application directory (which I assume is where your Game folder is. Relative paths do not usually work.

So it should look like this:

var arr:Array = ["app://Games/1.swf", "app://Games/2.swf"];

For more information/options, you can look at my answer to this question

查看更多
登录 后发表回答