チェンジセット 4548: as3/CannonML
- コミット日時:
- 2011/06/15 02:27:55 (1 年前)
- ファイル:
-
- as3/CannonML/trunk/archive/cml031.swc (追加)
- as3/CannonML/trunk/archive/cml031_asdoc.zip (追加)
- as3/CannonML/trunk/samples/CMLObjectSample (追加)
- as3/CannonML/trunk/samples/CMLObjectSample/CMLObjectSample.as (追加)
- as3/CannonML/trunk/samples/FirstSample/FirstSample.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/b3 (追加)
- as3/CannonML/trunk/src/org/si/b3/CMLMovieClip.as (追加)
- as3/CannonML/trunk/src/org/si/b3/CMLMovieClipSprite.as (追加)
- as3/CannonML/trunk/src/org/si/b3/CMLMovieClipTexture.as (追加)
- as3/CannonML/trunk/src/org/si/b3/modules (追加)
- as3/CannonML/trunk/src/org/si/b3/modules/CMLMovieClipControl.as (追加)
- as3/CannonML/trunk/src/org/si/b3/modules/CMLMovieClipFPS.as (追加)
- as3/CannonML/trunk/src/org/si/b3/modules/CMLMovieClipKeyLogger.as (追加)
- as3/CannonML/trunk/src/org/si/b3/modules/CMLMovieClipScene.as (追加)
- as3/CannonML/trunk/src/org/si/b3/modules/_cmlmovieclip_internal.as (追加)
- as3/CannonML/trunk/src/org/si/cml/CMLObject.as (更新) (8 diffs)
- as3/CannonML/trunk/src/org/si/cml/CMLSequence.as (更新) (11 diffs)
- as3/CannonML/trunk/src/org/si/cml/CannonML.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/cml/core/BMLParser.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/cml/extensions/Actor.as (更新) (2 diffs)
- as3/CannonML/trunk/src/org/si/cml/extensions/ActorFactory.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/cml/extensions/BulletRunner.as (更新) (1 diff)
- as3/CannonML/trunk/src/org/si/cml/extensions/ScopeLimitObject.as (更新) (4 diffs)
- as3/CannonML/trunk/src/org/si/cml/extensions/framework (削除)
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/CannonML/trunk/samples/FirstSample/FirstSample.as
r4539 r4548 1 1 package { 2 import flash.geom.*; 2 3 import flash.events.*; 3 4 import flash.display.*; 4 5 import org.si.cml.*; 5 6 7 // Simple example for the usage of cannonML 8 //-------------------------------------------------- 6 import frocessing.color.FColor; 7 8 // cannonML particle test 9 9 public class FirstSample extends Sprite { 10 //-------------------------------------------------- stage CML11 // CML は 砲台の動作を表現します.12 // CML text represents cannon behaviour13 public var stageCML:String = "py-160[px$??*100n{{[rw]}vy$?*10+2i40v~bm$i?(5)+2,45f5vd-10}w30]";14 10 11 // cannonML script 12 private var script:String = "bs,4,,10bm5,360f10{i30vw90br5,360,2,2f4{i30v~ko}w10ay0.05}"; 15 13 16 17 18 //-------------------------------------------------- constructor 19 function FirstSample() 20 { 21 addEventListener(Event.ADDED_TO_STAGE, _setup); 14 function FirstSample() { 15 CMLObject.initialize(true); 16 var seed:Particle = new Particle(); 17 seed.create(0, 0); 18 seed.execute(new CMLSequence(script)); 19 addChild(new Bitmap(Particle.field)); 20 addEventListener(Event.ENTER_FRAME, function(e:Event) : void { 21 Particle.field.colorTransform(Particle.field.rect, colt); 22 Particle.color = FColor.HSVtoValue(hue++, .75, 1, 1); 23 CMLObject.update(); 24 }); 22 25 } 23 26 24 25 26 27 //-------------------------------------------------- setup 28 private function _setup(e:Event) : void 29 { 30 removeEventListener(Event.ADDED_TO_STAGE, _setup); 31 32 // draw field 33 field = new Sprite(); 34 field.x = 120; 35 field.y = 160; 36 field.graphics.lineStyle(1, 0); 37 field.graphics.drawRect(-120, -160, 240, 320); 38 addChild(field); 39 40 41 // (1) 42 // 初期化のために CMLObject.initialize() を最初に呼び出します. 43 // call CMLObject.initialize() as first setup 44 CMLObject.initialize(true); 45 46 47 // (2) 48 // CMLSequence は,砲台の挙動を表現します 49 // cannonML 文字列 か bulletML XML をコンストラクタに渡してください. 50 // CMLSequence represents sequence of cannon behaiviors. 51 // pass cannonML text or bulletML xml to the constructor. 52 var stageSequence:CMLSequence = new CMLSequence(stageCML); 53 54 55 // (3) 56 // ステージシーケンスを実行するための stageCannon を生成します 57 // create stageCannon to execute stage sequence 58 var stageCannon:Cannon = new Cannon(0); 59 60 61 // (4) 62 // CMLObject.create() は CMLObject を CML ステージ上に生成します. 63 // 引数で,x, y 座標値を指定します. 64 // CMLObject.create() creates CMLObject in the CML stage. 65 // the arguments specify x and y coordinate. 66 stageCannon.create(0, -160); 67 68 69 // (5) 70 // CMLObject.execute() は CMLSequence を CMLObject に実行させます. 71 // また,この関数は CMLFiber (thread に相当) を返値としてかえします. 72 // CMLFiber を用いて,実行状態をコントロールしたり,様々な値にアクセスしたりできます. 73 // CMLObject.execute() executes CMLSequence with CMLObject. 74 // And it returns CMLFiber that represents thread executor. 75 // you can control execution and access any parameters by CMLFiber. 76 var stageFiber:CMLFiber = stageCannon.execute(stageSequence); 77 78 79 // frame handler 80 addEventListener(Event.ENTER_FRAME, _draw); 81 } 82 83 84 //-------------------------------------------------- ENTER_FRAME event handler 85 private function _draw(e:Event) : void 86 { 87 // (6) 88 // CMLObject.update() を各フレームで呼び出します. 89 // call CMLObject.update() in each frames 90 CMLObject.update(); 91 } 27 private var colt:ColorTransform = new ColorTransform(.875,.875,.875); 28 private var hue:Number = 0; 92 29 } 93 30 } 94 31 95 32 33 import flash.geom.Rectangle; 34 import flash.display.BitmapData; 35 import org.si.cml.CMLObject; 96 36 97 98 import flash.display.*; 99 import org.si.cml.*; 100 101 102 // cannons field 103 var field:Sprite; 104 105 106 107 108 // (0) 109 // CMLObject の継承クラスで,5個のコールバック関数をオーバーライドします. 110 // Define class extension of CMLObject, and override 5 callback functions. 111 class Cannon extends CMLObject { 112 // constructor 113 function Cannon(radius:Number) 114 { 115 createNewCannonShape(radius); 116 } 37 class Particle extends CMLObject { 38 static public var color:uint; 39 static public var field:BitmapData = new BitmapData(465, 465, false, 0); 40 static private var _freeList:Array = []; 41 static private var _rect:Rectangle = new Rectangle(0,0,3,3); 42 static private function _new() : Particle { return _freeList.pop() || new Particle(); } 117 43 118 119 // onCreate は,このオブジェクトが CML ステージ上に生成されたときに呼び出されます. 120 // CMLObject.create() か,"n/f" CMLコマンド実行時に内部から呼び出されます. 121 // "n/f" CMLコマンド時は,onNewObject/onFireObject で返した CMLObject の create() が内部で呼び出されています. 122 // onCreate is called when this object is created. 123 // This function is called from system when CMLObject.create() or "n" or "f" command in CML. 124 // When called from "n" or "f" command, the system calls create() of CMLObject that is returned from onNewObject/onFireObject. 125 override public function onCreate() : void 126 { 127 // フィールドに cannonShape を追加 128 // add cannonShape to the field 129 field.addChild(cannonShape); 130 131 // cannonShape の位置と回転方向を更新 132 // update position and angle of cannonShape 133 cannonShape.x = this.x; 134 cannonShape.y = this.y; 135 cannonShape.rotation = this.angle; 136 } 137 138 139 // onDestroy は,このオブジェクトが CML ステージ上から消えたときに呼び出されます. 140 // この関数は,CMLObject.destroy() が呼ばれた際に呼び出されます. 141 // より正確には,CMLObject.destroy() により破壊フラグがセットされ, 142 // 全てのオブジェクトの update が終了後,破壊フラグがチェックされて,その際に onDestroy が呼び出されます. 143 // onDestroy is called when this object is destroyed (or escaped) 144 // This function is called from system when CMLObject.destroy(). 145 // To be exact, the CMLObject.destroy() sets destruction flag, 146 // and after all updates, flags are checked and system calls all onDestroys. 147 override public function onDestroy() : void 148 { 149 // CMLObject.destructionStatus で destory() 呼び出しの際に引数で指定した値を参照できます. 150 // CMLObject.destructionStatus refers the number that is specifyed by your CMLObject.destory() call. 151 if (this.destructionStatus == 1) { 152 // 通常,destructionStatus == 0 でステージから逃避,1 でプレイヤーによる破壊を示します. 153 // Usually,destructionStatus == 0 means escape from stage, and 1 means destruction by player. 154 createExplosion(); 155 } 156 field.removeChild(cannonShape); 157 } 158 159 160 // onUpdate は,各 CMLObject.update() 呼び出し時に呼び出されます. 161 // onUpdate is called in each CMLObject.update(). 162 override public function onUpdate() : void 163 { 164 // cannonShape の位置と回転方向を更新 165 // CMLObject の x, y, angle プロパティは,そのCMLObjectの現在の座標と回転方向です. 166 // update position and angle of cannonShape 167 // the properties of CMLObject "x", "y"and "angle" represents coordinate and rotation. 168 cannonShape.x = this.x; 169 cannonShape.y = this.y; 170 cannonShape.rotation = this.angle; 171 172 // ステージからいなくなったら,destructionStatus = 0 で destroy() 呼び出し 173 // destroy() with destructionStatus of 0, when the object escape from the stage 174 if (this.x<-140 || this.x>140 || this.y<-180 || this.y>180) this.destroy(0); 175 } 176 177 178 // onNewObject は,"n" CMLコマンド実行時に呼び出されます.新たな CMLObject を返す必要があります. 179 // 返した新たな CMLObject は,適切な初期化を施され内部で create()/(必要なら)execute() されます. 180 // onNewObject is called by "n" command in CML, and it should return new CMLObject. 181 // The returned CMLObject is initialized and system calls create() and execute()(if necessary). 182 override public function onNewObject(args:Array) : CMLObject 183 { 184 // return new Cannon 185 return new Cannon(8); 186 } 187 188 189 // onFireObject は,"f" CMLコマンド実行時に呼び出されます.新たな CMLObject を返す必要があります. 190 // 返した新たな CMLObject は,適切な初期化を施され,内部で create()/(必要なら)execute() されます. 191 // onFireObject is called by "f" command in CML, and it should return new CMLObject. 192 // The returned CMLObject is initialized and system calls create() and execute()(if necessary). 193 override public function onFireObject(args:Array) : CMLObject 194 { 195 // return new Cannon 196 return new Cannon(4); 197 } 198 199 200 // shape 201 private var cannonShape:Shape; 202 203 204 // create new cannon shape 205 private function createNewCannonShape(radius:Number) : void 206 { 207 var graphics:Graphics; 208 cannonShape = new Shape(); 209 graphics = cannonShape.graphics; 210 if (radius > 0) { 211 graphics.lineStyle(2, 0x404080); 212 if (radius > 6) { 213 graphics.moveTo(0, 0); 214 graphics.lineTo(radius+4, 0); 215 } 216 graphics.beginFill(0xc0c0f0); 217 graphics.drawCircle(0, 0, radius); 218 graphics.endFill(); 219 } 220 } 221 222 223 // create explosion 224 private function createExplosion() : void 225 { 44 function Particle() {} 45 override public function onNewObject(args:Array) : CMLObject { return _new(); } 46 override public function onFireObject(args:Array) : CMLObject { return _new(); } 47 override public function onDestroy() : void { _freeList.push(this); } 48 override public function onUpdate() : void { 49 _rect.x = x+231; 50 _rect.y = y+231; 51 field.fillRect(_rect, color); 52 if (this.x<-235 || this.x>235|| this.y<-235 || this.y>235) this.destroy(0); 226 53 } 227 54 } as3/CannonML/trunk/src/org/si/cml/CMLObject.as
r4539 r4548 7 7 8 8 package org.si.cml { 9 import flash.geom.Point; 9 10 import org.si.cml.core.*; 10 11 import org.si.cml.namespaces._cml_internal; … … 38 39 override public function onDestroy() : void 39 40 { 40 // destructionStatus=1 means destruction . So, create an explosion.41 // destructionStatus=1 means destruction (as you like), create explosion particles. 41 42 if (destructionStatus == 1) _createExplosion(); 42 43 } … … 87 88 @example 1) Call the CMLObject.initialize() function first of all. 88 89 <listing version="3.0"> 89 // 1st argument is vertical scroll flag. 90 // 2nd argument is function to create new CMLObject. 91 CMLObject.initialize(true, newEnemy); 92 93 function newEnemy(args:Array) : CMLObject { 94 return new Enemy(); // Enemy class is your extention of CMLObject. 95 } 90 // 1st argument specifies scrolling direction (set true for vertical, false for horizontal). 91 CMLObject.initialize(true); 96 92 </listing> 97 93 @example 2) Create player object and marking it as "default target". … … 100 96 player.setAsDefaultTarget(); // Default target is the object to fire. 101 97 </listing> 102 @example 3-1) Create a new CMLSequence from cannonML or bulletML, and call create() and execute(). 103 <listing version="3.0"> 104 // Create sequence from "String of cannonML" or "XML of bulletML". 105 var motion:CMLSequence = new CMLSequence(String or XML); 106 107 ... 108 109 enemy.create(x, y); // Create enemy on the stage. 110 enemy.execute(motion); // Execute sequence. 111 </listing> 112 @example 3-2) Or create a new CMLSequence of stage, and call CMLObject.root.execute(). 98 @example 3) Create a new CMLSequence from cannonML or bulletML, and call create() and execute(). 113 99 <listing version="3.0"> 114 100 // Create stage sequence from "String of cannonML" or "XML of bulletML". 115 var stageSeq :CMLSequence = new CMLSequence(String or XML);101 var stageSequence:CMLSequence = new CMLSequence(String or XML); 116 102 117 103 ... 118 104 119 CMLObject.root.execute(stageSeq); // Execute stage sequence. 120 </listing> 121 @example 3-3) An example for a shoting CMLSequence of player. 122 <listing version="3.0"> 123 // Create shot sequence from "String of cannonML" or "XML of bulletML". 124 var shotSeq:CMLSequence = new CMLSequence(String or XML); 125 // Fiber to execute shoting sequence. 126 var shotFbr:CMLFiber = null; 127 128 ... 129 130 // player is an inherit of CMLObject. Execute shot sequence when shot button is pressed. 131 if (isPressed(SHOT_BUTTON)) { 132 shotFbr = player.execute(shotSeq); 133 } else { 134 // Stop the sequence when it's active and shot button was released. 135 if (shotFbr != null && shotFbr.isActive) { 136 shotFbr.destroy(); 137 shotFbr = null; 138 } 139 } 105 var root:Enemy = new Enemy(); // create one enemy as "root enemy" (usually transparent) 106 root.create(x, y); // Create root enemy on the cml field. 107 root.execute(stageSequence); // Execute stage sequence on root enemy. 140 108 </listing> 141 109 @example 4) Call CMLObject.update() once for each frame. 142 110 <listing version="3.0"> 143 addEventListener(Event.ENTER_FRAME, _onEnterFrame); // As you like111 addEventListener(Event.ENTER_FRAME, _onEnterFrame); 144 112 145 113 function _onEnterFrame(event:Event) : void { … … 227 195 _globalRank[0] = (r<_globalRankRangeMin) ? _globalRankRangeMin : (r>_globalRankRangeMax) ? _globalRankRangeMax : r; 228 196 } 229 197 230 198 // common properties 231 199 /** Construction ID, this value changes when the object is destroyed. … … 324 292 //------------------------------------------------------------ 325 293 // statics 326 static private var _activeObjects:CMLList = new CMLList();// active object list327 static private var _root:CMLRoot = null;// root object instance328 static private var _funcRand:Function = Math.random;// random function329 static private var _globalRankRangeMin:Number = 0;// the range of globalRank330 static private var _globalRankRangeMax:Number = 1;// the range of globalRank294 static private var _activeObjects:CMLList = new CMLList(); // active object list 295 static private var _root:CMLRoot = null; // root object instance 296 static private var _funcRand:Function = Math.random; // random function 297 static private var _globalRankRangeMin:Number = 0; // the range of globalRank 298 static private var _globalRankRangeMax:Number = 1; // the range of globalRank 331 299 /** @private */ 332 300 static _cml_internal var _globalRank:Array = new Array(10); // array of globalRank … … 449 417 /** <b>Call this function for each frame</b>. This function calls all CMLObject.onUpdate()s. */ 450 418 static public function update() : void 451 { 419 { 452 420 CMLFiber._cml_fiber_internal::_onUpdate(); 453 421 … … 599 567 public function getAimingAngle(target_:CMLObject, offx:Number=0, offy:Number=0) : Number 600 568 { 601 var sang:int = sin.index(_head), 602 cang:int = sang + sin.cos_shift; 603 var absx:Number = x + sin[cang]*offx - sin[sang]*offy; 604 var absy:Number = y + sin[sang]*offx + sin[cang]*offy; 569 var sang:int = sin.index(angleOnStage), cang:int = sang + sin.cos_shift, 570 absx:Number = x + sin[cang]*offx - sin[sang]*offy, 571 absy:Number = y + sin[sang]*offx + sin[cang]*offy; 605 572 return Math.atan2(target_.y-absy, target_.x-absx)*57.29577951308232 - _root._scrollAngle; 573 } 574 575 576 /** transform object local coordinate to global coordinate 577 * @param point on local coordinate. this instance is overwritten inside. 578 * @return point on global coordinate. this instance is that you passed as argument. 579 */ 580 public function transformLocalToGlobal(local:Point) : Point 581 { 582 var sang:int = sin.index(angleOnStage), cang:int = sang + sin.cos_shift, 583 glbx:Number = x + sin[cang]*local.x - sin[sang]*local.y, 584 glby:Number = y + sin[sang]*local.x + sin[cang]*local.y; 585 local.x = glbx; 586 local.y = glby; 587 return local; 588 } 589 590 591 /** transform global coordinate to object local coordinate 592 * @param point on global coordinate. this instance is overwritten inside. 593 * @return point on local coordinate. this instance is that you passed as argument. 594 */ 595 public function transformGlobalToLocal(global:Point) : Point 596 { 597 var sang:int = sin.index(-angleOnStage), cang:int = sang + sin.cos_shift, 598 locx:Number = sin[cang]*(global.x - x) - sin[sang]*(global.y - y), 599 locy:Number = sin[sang]*(global.x - x) + sin[cang]*(global.y - y); 600 global.x = locx; 601 global.y = locy; 602 return global; 606 603 } 607 604 as3/CannonML/trunk/src/org/si/cml/CMLSequence.as
r4456 r4548 16 16 * USAGE<br/> 17 17 * 1) CMLSequence(cannonML_String or bulletML_XML); creates a new sequence from certain cannonML/bulletML.<br/> 18 * 2) CMLObject.execute(CMLSequence); operates CMLObject's position and angle by CMLSequence.<br/>18 * 2) CMLObject.execute(CMLSequence); apply sequence to CMLObject.<br/> 19 19 * 3) CMLSequence.global; makes it global. You can access the child sequences of global sequence from everywhere.<br/> 20 20 * 4) CMLSequence.findSequence(); finds labeled sequence in cannonML/bulletML.<br/> … … 53 53 // variables 54 54 //------------------------------------------------------------ 55 private var label:String = null;56 private var childSequence:Object= null;57 private var parent:CMLSequence = null;58 private var non_labeled_count:int = 0;55 private var _label:String = null; 56 private var _childSequence:* = null; 57 private var _parent:CMLSequence = null; 58 private var _non_labeled_count:int = 0; 59 59 private var _global:Boolean = false; 60 60 /** @private */ … … 63 63 // global sequence 64 64 static private var globalSequences:Array = new Array(); 65 66 67 68 69 // functions 70 //------------------------------------------------------------ 71 /** Construct new sequence by a String of cannonML or an XML of bulletML. 72 * @param data Sequence data. Intstance of String or XML is available. String data is for CannonML, and XML data is for BulletML. 73 * @param globalSequence Flag of global sequence. 74 */ 75 function CMLSequence(data:* = null, globalSequence:Boolean = false) 76 { 77 super(ST_NO_LABEL); 78 79 label = null; 80 parent = null; 81 childSequence = new Object(); 82 non_labeled_count = 0; 83 require_argc = 0; 84 _global = false; 85 global = globalSequence; 86 87 if (data != null) { 88 if (data is XML) BMLParser._parse(this, data); 89 else CMLParser._parse(this, data); 90 } 91 } 92 93 94 /** @private */ 95 protected override function _setCommand(cmd:String) : CMLState 96 { 97 //_resetParameters(CMLObject._argumentCountOfNew); 98 return this; 99 } 100 65 66 67 101 68 102 69 // properties 103 70 //------------------------------------------------------------ 71 /** dictionary of child sequence, you can access by label */ 72 public function get childSequence() : * { return _childSequence; } 73 74 /** label of this sequence */ 75 public function get label() : String { return _label; } 76 104 77 /** Flag of global sequence. 105 78 * <p> … … 117 90 </listing> 118 91 */ 119 public function get global() : Boolean 120 { 121 return _global; 122 } 123 124 125 /** @private */ 92 public function get global() : Boolean { return _global; } 126 93 public function set global(makeGlobal:Boolean) : void 127 94 { … … 146 113 { 147 114 return (next==null || CMLState(next).type==ST_END); 115 } 116 117 118 119 120 // functions 121 //------------------------------------------------------------ 122 /** Construct new sequence by a String of cannonML or an XML of bulletML. 123 * @param data Sequence data. Intstance of String or XML is available. String data is for CannonML, and XML data is for BulletML. 124 * @param globalSequence Flag of global sequence. 125 */ 126 function CMLSequence(data:* = null, globalSequence:Boolean = false) 127 { 128 super(ST_NO_LABEL); 129 130 _label = null; 131 _parent = null; 132 _childSequence = {}; 133 _non_labeled_count = 0; 134 require_argc = 0; 135 _global = false; 136 global = globalSequence; 137 138 if (data != null) { 139 if (data is XML) BMLParser._parse(this, data); 140 else CMLParser._parse(this, data); 141 } 142 } 143 144 145 /** @private */ 146 protected override function _setCommand(cmd:String) : CMLState 147 { 148 //_resetParameters(CMLObject._argumentCountOfNew); 149 return this; 148 150 } 149 151 … … 255 257 256 258 // clear children 257 for (var key:String in childSequence) {258 childSequence[key].clear();259 delete childSequence[key];259 for (var key:String in _childSequence) { 260 _childSequence[key].clear(); 261 delete _childSequence[key]; 260 262 } 261 263 … … 296 298 if (idx == -1) { 297 299 // label_ does not include access operator "." 298 if (label_ in childSequence) returnchildSequence[label_];300 if (label_ in _childSequence) return _childSequence[label_]; 299 301 } else { 300 302 if (idx == 0) { 301 303 // first "." means root label 302 var root:CMLSequence = parent;303 while (root. parent != null) { root = root.parent; }304 var root:CMLSequence = _parent; 305 while (root._parent != null) { root = root._parent; } 304 306 return root.findSequence(label_.substr(1)); 305 307 } 306 308 // label_ includes access operator "." 307 309 var parent_label:String = label_.substr(0, idx); 308 if (parent_label in childSequence) {310 if (parent_label in _childSequence) { 309 311 var child_label:String = label_.substr(idx+1); 310 return childSequence[parent_label].findSequence(child_label);312 return _childSequence[parent_label].findSequence(child_label); 311 313 } 312 314 } 313 315 314 316 // seek brothers 315 return ( parent != null) ?parent.findSequence(label_) : null;317 return (_parent != null) ? _parent.findSequence(label_) : null; 316 318 } 317 319 … … 326 328 return null; 327 329 } 328 330 331 332 329 333 330 334 // internals … … 336 340 var seq:CMLSequence = new CMLSequence(); 337 341 seq.type = (label_ == null) ? ST_NO_LABEL : ST_LABEL; 338 seq. label = label_;342 seq._label = label_; 339 343 _addChild(seq); 340 344 return seq; … … 345 349 private function _addChild(seq:CMLSequence) : void 346 350 { 347 if (seq. label == null) {351 if (seq._label == null) { 348 352 // non-labeled sequence 349 seq. label = "#" + String(non_labeled_count);350 ++ non_labeled_count;351 } 352 353 if (seq. label in childSequence) throw Error("sequence label confliction; "+seq.label+" in "+label);354 seq. parent = this;355 childSequence[seq.label] = seq;353 seq._label = "#" + String(_non_labeled_count); 354 ++_non_labeled_count; 355 } 356 357 if (seq._label in _childSequence) throw Error("sequence label confliction; "+seq._label+" in "+label); 358 seq._parent = this; 359 _childSequence[seq._label] = seq; 356 360 } 357 361 … … 416 420 417 421 // verify all child sequences 418 for each (var seq:CMLSequence in childSequence) { seq.verify(); }422 for each (var seq:CMLSequence in _childSequence) { seq.verify(); } 419 423 } 420 424 as3/CannonML/trunk/src/org/si/cml/CannonML.as
r4539 r4548 7 7 8 8 package org.si.cml { 9 /** Cannon ML */10 class CannonML {9 /** Cannon ML infomation */ 10 public class CannonML { 11 11 /** Version information */ 12 12 static public const VERSION:String = "0.3.1"; as3/CannonML/trunk/src/org/si/cml/core/BMLParser.as
r4456 r4548 599 599 internal var bseq:String = "nws"; 600 600 internal var bv:String = "0"; 601 function seqinfo() {} 601 602 } as3/CannonML/trunk/src/org/si/cml/extensions/Actor.as
r4539 r4548 11 11 12 12 13 /** <b>Extension of CMLObject</b> that scope, life, hit test, drawing priority and management of instances are implemented. <br/>13 /** Extension of CMLObject that implements scope, life, hit test, drawing priority and management of instances. <br/> 14 14 * You have to call Actor.initialize() first, and you have to call CMLObject.update() and Actor.draw() for each frame.<br/> 15 15 * Actor.initialize() registers some user define commands as below, … … 70 70 _nextEval._prevEval = _prevEval; 71 71 if (enable) { 72 var evalLayer:Actor = _evalLayers[_evalIDNumber];72 var evalLayer:Actor = _evalLayers[_evalIDNumber]; 73 73 _prevEval = evalLayer._prevEval; 74 74 _nextEval = evalLayer; as3/CannonML/trunk/src/org/si/cml/extensions/ActorFactory.as
r4456 r4548 12 12 13 13 /** Factory class of Actors. 14 * 14 @example basic usage. 15 <listing version="3.0"> 16 public class Bullet extends Actor { 17 } 18 ... 19 20 var bulletFactory:ActorFactory = new ActorFactory(Bullet); 21 22 ... 23 24 var newBullet:Bullet = bulletFactory.newInstance(); 25 </listing> 15 26 */ 16 27 public class ActorFactory as3/CannonML/trunk/src/org/si/cml/extensions/BulletRunner.as
r4539 r4548 15 15 16 16 /** The BulletRunner is simple class to apply CannonML. 17 @example basic usage. 18 <listing version="3.0"> 19 // apply bullet runner to your own instance with callback functions 20 var br:BulletRunner = BulletRunner.apply(yourInstance, {"onCreate":onCreate...}) 21 // and run sequence on bullet runner 22 br.runSequence("cml text", bml_xml or CMLSequence); 23 </listing> 17 24 */ 18 25 public class BulletRunner extends ScopeLimitObject as3/CannonML/trunk/src/org/si/cml/extensions/ScopeLimitObject.as
r4539 r4548 11 11 12 12 13 /** <b>Extension of CMLObject</b> that scope limitation is implemented. <br/>13 /** Extension of CMLObject that implements scope limitation. <br/> 14 14 * You have to call ScopeLimitObject.initialize() first, and you have to call CMLObject.update() for each frame.<br/> 15 15 * ScopeLimitObject.initialize() registers some user define commands as below, … … 40 40 public var scopeYmax:Number; 41 41 /** The availabirity of scope check */ 42 public var enableScope:Boolean = true;42 public var scopeEnabled:Boolean = true; 43 43 44 44 /** default value of the available scopes range */ … … 77 77 public function get isEscaped() : Boolean 78 78 { 79 return ( enableScope&& (y<scopeYmin || x<scopeXmin || y>scopeYmax || x>scopeXmax));79 return (scopeEnabled && (y<scopeYmin || x<scopeXmin || y>scopeYmax || x>scopeXmax)); 80 80 } 81 81 … … 206 206 { 207 207 if (CMLObject.root == null) { 208 CMLSequence.registerUserCommand("scon", function(f:CMLFiber, a:Array) : void { Actor(f.object). enableScope= true; });209 CMLSequence.registerUserCommand("scoff", function(f:CMLFiber, a:Array) : void { Actor(f.object). enableScope= false; });208 CMLSequence.registerUserCommand("scon", function(f:CMLFiber, a:Array) : void { Actor(f.object).scopeEnabled = true; }); 209 CMLSequence.registerUserCommand("scoff", function(f:CMLFiber, a:Array) : void { Actor(f.object).scopeEnabled = false; }); 210 210 } 211 211 return CMLObject.initialize(vertical_);

