![]()
2011.09.30 Kikuchi
2011.08.08 takaiw
2011.07.01 knockknock
2011.05.17 Naoki Muramatsu
2011.05.02 knockknock
![]()
![]()
Naoki Muramatsu (1件) Twitter:@Stryfy.
deco-dekai (1件)
ビートダウンパートでご飯何杯も食べられます。
ハードコア・テクニカルディレクターを目指して日々精進。
yanbou (6件)
犬と猫で、家が毎日運動会のフラッシュデベロッパー。
ビールから発泡酒へ変更で節約中。
chikatherrsix (8件) メタル界のフラッシュデベロッパー。またある時はメタルギタリスト。オーサリング中もヘッドバンギングは絶やさない。
akuze (2件)
2003年からユナイティアに寄生しているフラッシュデベロッパー。
シルクドソレイユとカナダが好き。
knockknock (16件)
小遣い2万円のフラッシュデベロッパー。
帰りが遅いのにキレる嫁をだましだまし制作中・・・。
takaiw (18件) フラッシュデベロッパー。遊びでゲームを作るのも好きです。外見に似合わないイラストを描くのも好きです。とにかく作るのが好きです。
![]()
HOME > AIRオートアップデート
オートアップデートとは
AIRアプリをインストールしているユーザーに
インストールされているバージョンより
新しいバージョンがアップされてます、
と伝えることである。
AIRはアプリケーションなので
当然インターネットに繋がらない環境もありうる。
ということで
流れは以下である。
1.回線チェック
↓OK →NG 通常表示
2.バージョンデータロード
↓OK →NG 通常表示
3.バージョンチェック
↓アップデート有り →なし 通常表示
4.アップデートするしない確認
↓する →しない 通常表示
5.アップデート
private var _monitor:URLMonitor;//通信モニター
//通信チェック
private function checkHttp():void {
this._monitor = new URLMonitor(new URLRequest("http://www.adobe.com"));
this._monitor.addEventListener(StatusEvent.STATUS, announceStatus);
this._monitor.start();
}
//通信監視
private function announceStatus(e:StatusEvent):void {
if (this._monitor.available) {
//バージョンデータロードへ
} else {
//通常表示へ
}
}
private var _versionXML:XML;
public function loadXml():void {
var ran:uint = Math.floor(Math.random() * 10000000000);
var loader:URLLoader = new URLLoader;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
loader.load(new URLRequest("version.xml?" + ran));
}
//ロードエラー
private function errorHandler(e:IOErrorEvent):void {
//通常表示へ
}
//ロード完了
public function completeHandler(e:Event):void {
this._versionXML = new XML(e.target.data);
//バージョンチェックへ
}
//バージョン
public function rVersion():String {
return this._versionXML.version.@latest;
}
XMLは以下
<?xml version="1.0" encoding="UTF-8" ?> <clipWindow> <version latest="1.0" /> </clipWindow>
private var _update:UpdateClass;//アップデートウィンドウ
private var _appVersion:String;//現在のバージョン
private var _newVersion:String;//新しいバージョン
//バージョンチェック
private function checkVersion(e:Event):void {
var appXml:XML = NativeApplication.nativeApplication.applicationDescriptor;
var ns:Namespace = appXml.namespace();
this._appVersion = appXml.ns::version[0];
this._newVersion = this._versionData.rVersion();
if (this._newVersion != this._appVersion) {
this._update = new UpdateClass(this._appVersion, this._newVersion);
this.addChild(this._update);
} else {
//通常表示へ
}
}
private var _airLoader:URLLoader;
//ダウンロード
private function downloadAirFile(e:MouseEvent):void {
this._airLoader = new URLLoader();
this._airLoader.dataFormat = URLLoaderDataFormat.BINARY;
this._airLoader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
this._airLoader.addEventListener(Event.COMPLETE, downloadAirFileCompleteHandler);
this._airLoader.load(new URLRequest("clipWindow.air"));
}
//ダウンロードエラー
private function errorHandler(e:IOErrorEvent):void {
//エラー表示
}
//アップデート
private function downloadAirFileCompleteHandler(e:Event):void {
var airFile:File = File.applicationStorageDirectory.resolvePath("clipWindow.air");
var fs:FileStream = new FileStream();
fs.open(airFile, FileMode.WRITE);
fs.writeBytes(this._airLoader.data);
fs.close();
var updater:Updater = new Updater();
updater.update(airFile, this._newVersion);
}
以上、チェックが面倒だが
今後を考えると入れておくべきである。

yanbou
犬と猫で、家が毎日運動会のフラッシュデベロッパー。
ビールから発泡酒へ変更で節約中。