【发布时间】:2023-04-11 09:14:01
【问题描述】:
我正在使用 Flash 6 Air,AS3 开发移动应用程序,我想知道是否有可能制作自动更新功能,当用户打开应用程序时,它会查看更新。
所以你能帮我解决这个要求并给我我必须使用的代码吗?!!
提前致谢。
【问题讨论】:
标签: android actionscript-3 mobile air flash-cs5
我正在使用 Flash 6 Air,AS3 开发移动应用程序,我想知道是否有可能制作自动更新功能,当用户打开应用程序时,它会查看更新。
所以你能帮我解决这个要求并给我我必须使用的代码吗?!!
提前致谢。
【问题讨论】:
标签: android actionscript-3 mobile air flash-cs5
这里有两个选项
一个示例下载器
public function start():void
{
var fileLoader:URLLoader = new URLLoader
fileLoader.dataFormat = URLLoaderDataFormat.BINARY;
fileLoader.addEventListener(Event.COMPLETE,downloadSuccess);
var url:URLRequest = new URLRequest("http://www.example.com/updates/"+targetVersion+".apk");
fileLoader.load(url);
}
private function downloadSuccess(event:Event):void
{
var fileLoader:URLLoader = event.target as URLLoader;
fileLoader.removeEventListener(Event.COMPLETE,downloadSuccess);
var fs:FileStream = new FileStream();
var file:File = File.userDirectory.resolvePath(targetVersion+".apk");
fs.open(file,FileMode.WRITE);
fs.writeBytes(fileLoader.data);
fs.close();
//insert native extension call here.
}
然后您需要一个 ANE 来触发 android 包安装程序。有plenty of ANE tutorials out there,但没有一个具体涵盖您想要的内容。我推荐starting with this one.
【讨论】: