home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 164
/
MOBICLIC164.ISO
/
mac
/
index.swf
/
scripts
/
com
/
milanpresse
/
capsule
/
GameEngineCapsule.as
< prev
next >
Wrap
Text File
|
2014-05-13
|
5KB
|
162 lines
package com.milanpresse.capsule
{
import com.milanpresse.engine.Context;
import com.milanpresse.engine.Engine;
import com.milanpresse.engine.HostContainer;
import com.milanpresse.engine.config.Config;
import com.milanpresse.engine.typeargument.ModuleCallerParameter;
import flash.display.Sprite;
import flash.system.Security;
public class GameEngineCapsule extends Sprite implements ICapsule
{
private var _engine;
protected var _host;
public var isHost:Boolean = false;
protected var _callback:Function = null;
private var _config:ICapsuleConfig = null;
private var _inHost:Boolean;
private var _initParams:Object = null;
private var _engineLib:LoadLib;
private var _contextInitParams:Object = null;
public function GameEngineCapsule()
{
super();
Security.allowDomain("*");
if(parent != null)
{
this._inHost = false;
this.init();
}
else
{
this._inHost = true;
}
}
public function get config() : ICapsuleConfig
{
return this._config as Config;
}
public function set config(param1:ICapsuleConfig) : void
{
this._config = param1;
}
public function get host() : *
{
return this._host as HostContainer;
}
public function get engine() : *
{
return this._engine as Engine;
}
public function init(param1:Object = null) : void
{
this._initParams = param1 == null ? {} : param1;
this._contextInitParams = this._initParams.initParams == undefined ? {} : this._initParams.initParams;
this.loadEngine(this.engineLoaded);
}
private function loadEngine(param1:Function) : void
{
var _loc2_:* = null;
if(this._inHost == false && this.isHost == false)
{
_loc2_ = "../../HOTE/gameEngine_as3/bin/GameEngine/library.swf";
}
else if(this._inHost == false && this.isHost == true)
{
_loc2_ = "DATA/HOTE/gameEngine_as3/bin/GameEngine/library.swf";
}
else
{
_loc2_ = this.getDirectoryPathOfFile(this._initParams.context.path) + "/DATA/HOTE/gameEngine_as3/bin/GameEngine/library.swf";
}
this._engineLib = new LoadLib("com.milanpresse.engine.Engine",_loc2_,this.engineLoaded,{"app":this});
}
private function engineLoaded() : void
{
if(this._inHost == false)
{
this.initAsHost();
}
else
{
this.initAsChild();
}
}
private function initAsHost() : void
{
var _loc1_:Context = new Context();
_loc1_.urlParameters = this.loaderInfo.parameters;
_loc1_.hostContext = _loc1_;
_loc1_.path = this.loaderInfo.url;
_loc1_.data = this;
this._contextInitParams.callerParameters = new ModuleCallerParameter();
_loc1_.initParams = this._contextInitParams;
this._host = new HostContainer(this);
this._engine = new Engine(this.start,_loc1_) as Engine;
}
private function initAsChild(param1:* = null) : void
{
this._callback = this._initParams.callback;
var _loc2_:Context = this._initParams.context;
this._host = new HostContainer(_loc2_.data);
var _loc3_:Context = new Context();
_loc3_.hostContext = _loc2_;
_loc3_.path = this.loaderInfo.url;
_loc3_.data = this;
_loc3_.initParams = this._contextInitParams;
this._engine = new Engine(this.initEnd,_loc3_);
}
private function initEnd(param1:* = null) : void
{
this._callback();
}
private function getDirectoryPathOfFile(param1:String) : String
{
var _loc2_:Array = unescape(param1).replace(/\\/g,"/").split("/");
_loc2_.pop();
return _loc2_.join("/");
}
public function start(param1:Object = null) : void
{
}
public function destroy() : void
{
this._engine.destroy();
this._engineLib.destroy();
}
public function sleep() : void
{
}
public function wake() : void
{
}
}
}