-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
174 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.core.Common | ||
{ | ||
import com.core.Utils.File.OpenFile; | ||
|
||
import flash.display.Loader; | ||
import flash.events.Event; | ||
import flash.filesystem.File; | ||
import flash.net.URLRequest; | ||
import flash.system.ApplicationDomain; | ||
import flash.system.LoaderContext; | ||
import flash.utils.ByteArray; | ||
|
||
public class UpDateManager implements IDispose | ||
{ | ||
private var completeFun:Function; | ||
public function UpDateManager() | ||
{ | ||
|
||
} | ||
|
||
|
||
/**执行更新*/ | ||
public function UpDate(onComplete:Function):void | ||
{ | ||
completeFun = onComplete; | ||
// 如果是debug 则每次都覆盖更新逻辑swf | ||
// 后面还会添加版本比对 | ||
if(Singleton.platform.Debug) | ||
{ | ||
updateLogicSWF(onSWFSaveComplete); | ||
} | ||
else | ||
{ | ||
loaderLogicSWF(); | ||
} | ||
|
||
function onSWFSaveComplete(e:Event):void | ||
{ | ||
loaderLogicSWF(); | ||
} | ||
|
||
function onSWFLoaderComplete(e:Event):void | ||
{ | ||
loaderLogicSWF(); | ||
} | ||
|
||
|
||
} | ||
|
||
/***加载逻辑SWF */ | ||
private function loaderLogicSWF():void | ||
{ | ||
var path:String = File.applicationDirectory.resolvePath("asset").url + "/TeamX_Moblie.swf"; | ||
var request:URLRequest = new URLRequest(path); | ||
var context:LoaderContext = new LoaderContext(); | ||
context.applicationDomain = ApplicationDomain.currentDomain; | ||
var loader:Loader = new Loader(); | ||
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE , onComplete); | ||
loader.load(request,context); | ||
|
||
function onComplete(e:Event):void | ||
{ | ||
if(completeFun != null) | ||
{ | ||
completeFun(context.applicationDomain.getDefinition("TeamX_Moblie")); | ||
} | ||
} | ||
} | ||
|
||
|
||
/***更新逻辑SWF */ | ||
private function updateLogicSWF(onFileOpenedToSave:Function):void | ||
{ | ||
var path:String = File.applicationDirectory.resolvePath("asset").nativePath + "/TeamX_Moblie.swf"; | ||
var f:File = new File(path); | ||
if(f.exists) | ||
{ | ||
trace("逻辑swf已经存在!"); | ||
f.deleteFile(); | ||
} | ||
var name:String = File.applicationDirectory.url + "TeamX_Moblie.swf"; | ||
f = new File(name); | ||
var ba:ByteArray = OpenFile.open(f); | ||
OpenFile.writeAsync(ba,path,onFileOpenedToSave); | ||
} | ||
|
||
public function dispose():void | ||
{ | ||
completeFun = null; | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters