| 1 |
/* |
|---|
| 2 |
* Copyright(c) 2008 the Spark project. |
|---|
| 3 |
* |
|---|
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 5 |
* you may not use this file except in compliance with the License. |
|---|
| 6 |
* You may obtain a copy of the License at |
|---|
| 7 |
* |
|---|
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 9 |
* |
|---|
| 10 |
* Unless required by applicable law or agreed to in writing, software |
|---|
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
|---|
| 13 |
* either express or implied. See the License for the specific language |
|---|
| 14 |
* governing permissions and limitations under the License. |
|---|
| 15 |
*/ |
|---|
| 16 |
|
|---|
| 17 |
package{ |
|---|
| 18 |
import flash.display.*; |
|---|
| 19 |
import flash.events.*; |
|---|
| 20 |
import flash.net.*; |
|---|
| 21 |
import flash.system.LoaderContext; |
|---|
| 22 |
import flash.text.*; |
|---|
| 23 |
import flash.system.ApplicationDomain; |
|---|
| 24 |
import flash.system.System; |
|---|
| 25 |
import flash.system.Security; |
|---|
| 26 |
|
|---|
| 27 |
import jp.cohesion.core.Kernel; |
|---|
| 28 |
import jp.cohesion.common.Logger; |
|---|
| 29 |
import jp.cohesion.test.DummySocket; |
|---|
| 30 |
|
|---|
| 31 |
/* == [Project Cohesion] =================================================== */ |
|---|
| 32 |
|
|---|
| 33 |
[Frame(factoryClass="Preloader")] |
|---|
| 34 |
/** |
|---|
| 35 |
* Cohesion ブートストラップメインムービ |
|---|
| 36 |
* |
|---|
| 37 |
* @author $Author$ |
|---|
| 38 |
* @revision $Rev$ |
|---|
| 39 |
* @date $Date$ |
|---|
| 40 |
*/ |
|---|
| 41 |
public class Main extends Sprite { |
|---|
| 42 |
// コンストラクタ /////////////////////////////////////////////////////////////////// |
|---|
| 43 |
// Constructors // |
|---|
| 44 |
///////////////////////////////////////////////////////////////////////////////////// |
|---|
| 45 |
|
|---|
| 46 |
/** |
|---|
| 47 |
* デフォルトの設定を用いてオブジェクトを構築するコンストラクタ |
|---|
| 48 |
*/ |
|---|
| 49 |
public function Main(){ |
|---|
| 50 |
super(); |
|---|
| 51 |
|
|---|
| 52 |
Logger.DebugMode = CHConfig.DEBUG_MODE; |
|---|
| 53 |
Logger.TraceMode = true; |
|---|
| 54 |
|
|---|
| 55 |
Security.loadPolicyFile("xmlsocket://" + CHConfig.HOST + ":" + CHConfig.PORT); |
|---|
| 56 |
_server = new XMLSocket(); |
|---|
| 57 |
//_server = new DummySocket(); |
|---|
| 58 |
_singleton = this; |
|---|
| 59 |
_sharedObject = SharedObject.getLocal(CHConfig.SHARED_OBJECT_NAME); |
|---|
| 60 |
|
|---|
| 61 |
this.addEventListener(Event.ADDED, onAdded); |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
/** |
|---|
| 65 |
* Cohesion Kernelを起動します。 |
|---|
| 66 |
* |
|---|
| 67 |
* @param evt |
|---|
| 68 |
*/ |
|---|
| 69 |
private function onAdded(evt:Event):void { |
|---|
| 70 |
this.removeEventListener(Event.ADDED, onAdded); |
|---|
| 71 |
|
|---|
| 72 |
_kernel = new Kernel(); |
|---|
| 73 |
addChild(_kernel); |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
// 内部フィールド定義 /////////////////////////////////////////////////////////////// |
|---|
| 77 |
// Fields // |
|---|
| 78 |
///////////////////////////////////////////////////////////////////////////////////// |
|---|
| 79 |
|
|---|
| 80 |
/** */ |
|---|
| 81 |
public static const MESSAGE_DIGEST:String = "md5"; |
|---|
| 82 |
/** */ |
|---|
| 83 |
public static const CIPHER:String = "blowfish-cbc"; |
|---|
| 84 |
|
|---|
| 85 |
// プロパティ /////////////////////////////////////////////////////////////////////// |
|---|
| 86 |
// Properties // |
|---|
| 87 |
///////////////////////////////////////////////////////////////////////////////////// |
|---|
| 88 |
|
|---|
| 89 |
/** */ |
|---|
| 90 |
private static var _singleton:Main; |
|---|
| 91 |
/** |
|---|
| 92 |
* プリローダ使用の際、rootプロパティがnullになってしまう問題に対応。<br/> |
|---|
| 93 |
* via <a href="http://d.hatena.ne.jp/flashrod/20070317">http://d.hatena.ne.jp/flashrod/20070317</a><br/> |
|---|
| 94 |
* |
|---|
| 95 |
* @return このムービークリップ自身 |
|---|
| 96 |
*/ |
|---|
| 97 |
public static function get instance():Main { |
|---|
| 98 |
return _singleton; |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
/** Cohesionカーネル */ |
|---|
| 102 |
private static var _kernel:Kernel; |
|---|
| 103 |
/** |
|---|
| 104 |
* Cohesionカーネル |
|---|
| 105 |
* @return Cohesionカーネル |
|---|
| 106 |
*/ |
|---|
| 107 |
public static function get kernel():Kernel { return _kernel; } |
|---|
| 108 |
|
|---|
| 109 |
/** XMLSocket接続 */ |
|---|
| 110 |
private static var _server:XMLSocket; |
|---|
| 111 |
/** |
|---|
| 112 |
* Cohesion ServerへのXMLSocket接続 |
|---|
| 113 |
* @return XMLSocket接続 |
|---|
| 114 |
*/ |
|---|
| 115 |
public static function get server():XMLSocket { return _server; } |
|---|
| 116 |
|
|---|
| 117 |
/** SharedObject */ |
|---|
| 118 |
private static var _sharedObject:SharedObject; |
|---|
| 119 |
/** |
|---|
| 120 |
* ローカル保持データ |
|---|
| 121 |
* @return ローカル保持データ |
|---|
| 122 |
*/ |
|---|
| 123 |
public static function get localdata():Object { return _sharedObject.data; } |
|---|
| 124 |
|
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
} |
|---|