チェンジセット 4548: as3/CannonML

差分発生行の前後
無視リスト:
コミット日時:
2011/06/15 02:27:55 (1 年前)
コミッタ:
keim
ログメッセージ:

cannonml v0.31 update

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/CannonML/trunk/samples/FirstSample/FirstSample.as

    r4539 r4548  
    11package { 
     2    import flash.geom.*; 
    23    import flash.events.*; 
    34    import flash.display.*; 
    45    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 
    99    public class FirstSample extends Sprite { 
    10     //-------------------------------------------------- stage CML  
    11         // CML は 砲台の動作を表現します. 
    12         // CML text represents cannon behaviour 
    13         public var stageCML:String = "py-160[px$??*100n{{[rw]}vy$?*10+2i40v~bm$i?(5)+2,45f5vd-10}w30]"; 
    1410         
     11        // cannonML script 
     12        private var script:String = "bs,4,,10bm5,360f10{i30vw90br5,360,2,2f4{i30v~ko}w10ay0.05}"; 
    1513         
    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            }); 
    2225        } 
    2326         
    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; 
    9229    } 
    9330} 
    9431 
    9532 
     33import flash.geom.Rectangle; 
     34import flash.display.BitmapData; 
     35import org.si.cml.CMLObject; 
    9636 
    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     } 
     37class 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(); } 
    11743     
    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); 
    22653    } 
    22754} 
  • as3/CannonML/trunk/src/org/si/cml/CMLObject.as

    r4539 r4548  
    77 
    88package org.si.cml { 
     9    import flash.geom.Point; 
    910    import org.si.cml.core.*; 
    1011    import org.si.cml.namespaces._cml_internal; 
     
    3839    override public function onDestroy() : void 
    3940    { 
    40         // destructionStatus=1 means destruction. So, create an explosion
     41        // destructionStatus=1 means destruction (as you like), create explosion particles
    4142        if (destructionStatus == 1) _createExplosion(); 
    4243    } 
     
    8788@example 1) Call the CMLObject.initialize() function first of all.  
    8889<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). 
     91CMLObject.initialize(true); 
    9692</listing> 
    9793@example 2) Create player object and marking it as "default target". 
     
    10096player.setAsDefaultTarget();            // Default target is the object to fire. 
    10197</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(). 
    11399<listing version="3.0"> 
    114100// Create stage sequence from "String of cannonML" or "XML of bulletML". 
    115 var stageSeq:CMLSequence = new CMLSequence(String or XML); 
     101var stageSequence:CMLSequence = new CMLSequence(String or XML); 
    116102 
    117103 ... 
    118104 
    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 
     105var root:Enemy = new Enemy();   // create one enemy as "root enemy" (usually transparent) 
     106root.create(x, y);              // Create root enemy on the cml field. 
     107root.execute(stageSequence);    // Execute stage sequence on root enemy. 
    140108</listing> 
    141109@example 4) Call CMLObject.update() once for each frame. 
    142110<listing version="3.0"> 
    143 addEventListener(Event.ENTER_FRAME, _onEnterFrame); // As you like 
     111addEventListener(Event.ENTER_FRAME, _onEnterFrame); 
    144112 
    145113function _onEnterFrame(event:Event) : void { 
     
    227195            _globalRank[0] = (r<_globalRankRangeMin) ? _globalRankRangeMin : (r>_globalRankRangeMax) ? _globalRankRangeMax : r; 
    228196        } 
    229  
     197         
    230198        // common properties 
    231199        /** Construction ID, this value changes when the object is destroyed. 
     
    324292    //------------------------------------------------------------ 
    325293        // statics 
    326         static private var _activeObjects:CMLList = new CMLList();      // active object list 
    327         static private var _root:CMLRoot = null;                        // root object instance 
    328         static private var _funcRand:Function = Math.random;            // random function 
    329         static private var _globalRankRangeMin:Number = 0;              // the range of globalRank 
    330         static private var _globalRankRangeMax:Number = 1;              // the range of globalRank 
     294        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 
    331299        /** @private */ 
    332300        static _cml_internal var _globalRank:Array = new Array(10);     // array of globalRank 
     
    449417        /** <b>Call this function for each frame</b>. This function calls all CMLObject.onUpdate()s. */ 
    450418        static public function update() : void 
    451         {             
     419        { 
    452420            CMLFiber._cml_fiber_internal::_onUpdate(); 
    453421             
     
    599567        public function getAimingAngle(target_:CMLObject, offx:Number=0, offy:Number=0) : Number 
    600568        {             
    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; 
    605572            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; 
    606603        } 
    607604         
  • as3/CannonML/trunk/src/org/si/cml/CMLSequence.as

    r4456 r4548  
    1616     *  USAGE<br/> 
    1717     *  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/> 
    1919     *  3) CMLSequence.global; makes it global. You can access the child sequences of global sequence from everywhere.<br/> 
    2020     *  4) CMLSequence.findSequence(); finds labeled sequence in cannonML/bulletML.<br/> 
     
    5353    // variables 
    5454    //------------------------------------------------------------ 
    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; 
    5959        private  var _global:Boolean = false; 
    6060        /** @private */  
     
    6363        // global sequence 
    6464        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         
    10168         
    10269    // properties 
    10370    //------------------------------------------------------------ 
     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         
    10477        /** Flag of global sequence. 
    10578         *  <p> 
     
    11790</listing> 
    11891         */ 
    119         public function get global() : Boolean 
    120         { 
    121             return _global; 
    122         } 
    123  
    124  
    125         /** @private */ 
     92        public function get global() : Boolean { return _global; } 
    12693        public function set global(makeGlobal:Boolean) : void 
    12794        { 
     
    146113        { 
    147114            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; 
    148150        } 
    149151         
     
    255257             
    256258            // 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]; 
    260262            } 
    261263             
     
    296298            if (idx == -1) { 
    297299                // label_ does not include access operator "." 
    298                 if (label_ in childSequence) return childSequence[label_]; 
     300                if (label_ in _childSequence) return _childSequence[label_]; 
    299301            } else { 
    300302                if (idx == 0) { 
    301303                    // 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; } 
    304306                    return root.findSequence(label_.substr(1)); 
    305307                } 
    306308                // label_ includes access operator "." 
    307309                var parent_label:String = label_.substr(0, idx); 
    308                 if (parent_label in childSequence) {  
     310                if (parent_label in _childSequence) {  
    309311                    var child_label:String = label_.substr(idx+1); 
    310                     return childSequence[parent_label].findSequence(child_label); 
     312                    return _childSequence[parent_label].findSequence(child_label); 
    311313                } 
    312314            } 
    313315             
    314316            // seek brothers 
    315             return (parent != null) ? parent.findSequence(label_) : null; 
     317            return (_parent != null) ? _parent.findSequence(label_) : null; 
    316318        } 
    317319 
     
    326328            return null; 
    327329        } 
    328  
     330         
     331         
     332         
    329333        
    330334    // internals 
     
    336340            var seq:CMLSequence = new CMLSequence(); 
    337341            seq.type = (label_ == null) ? ST_NO_LABEL : ST_LABEL; 
    338             seq.label = label_; 
     342            seq._label = label_; 
    339343            _addChild(seq); 
    340344            return seq; 
     
    345349        private function _addChild(seq:CMLSequence) : void 
    346350        { 
    347             if (seq.label == null) { 
     351            if (seq._label == null) { 
    348352                // 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; 
    356360        } 
    357361 
     
    416420          
    417421            // verify all child sequences 
    418             for each (var seq:CMLSequence in childSequence) { seq.verify(); } 
     422            for each (var seq:CMLSequence in _childSequence) { seq.verify(); } 
    419423        } 
    420424 
  • as3/CannonML/trunk/src/org/si/cml/CannonML.as

    r4539 r4548  
    77 
    88package org.si.cml { 
    9     /** Cannon ML */ 
    10     class CannonML { 
     9    /** Cannon ML infomation */ 
     10    public class CannonML { 
    1111        /** Version information */ 
    1212        static public const VERSION:String = "0.3.1"; 
  • as3/CannonML/trunk/src/org/si/cml/core/BMLParser.as

    r4456 r4548  
    599599    internal var bseq:String = "nws"; 
    600600    internal var bv:String = "0"; 
     601    function seqinfo() {} 
    601602} 
  • as3/CannonML/trunk/src/org/si/cml/extensions/Actor.as

    r4539 r4548  
    1111     
    1212     
    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/> 
    1414     *  You have to call Actor.initialize() first, and you have to call CMLObject.update() and Actor.draw() for each frame.<br/> 
    1515     *  Actor.initialize() registers some user define commands as below, 
     
    7070            _nextEval._prevEval = _prevEval; 
    7171            if (enable) { 
    72                var evalLayer:Actor = _evalLayers[_evalIDNumber]; 
     72                var evalLayer:Actor = _evalLayers[_evalIDNumber]; 
    7373                _prevEval = evalLayer._prevEval; 
    7474                _nextEval = evalLayer; 
  • as3/CannonML/trunk/src/org/si/cml/extensions/ActorFactory.as

    r4456 r4548  
    1212     
    1313    /** Factory class of Actors. 
    14      *   
     14@example basic usage. 
     15<listing version="3.0"> 
     16public class Bullet extends Actor { 
     17
     18    ... 
     19     
     20var bulletFactory:ActorFactory = new ActorFactory(Bullet); 
     21 
     22    ... 
     23     
     24var newBullet:Bullet = bulletFactory.newInstance(); 
     25</listing> 
    1526     */ 
    1627    public class ActorFactory 
  • as3/CannonML/trunk/src/org/si/cml/extensions/BulletRunner.as

    r4539 r4548  
    1515     
    1616    /** 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 
     20var br:BulletRunner = BulletRunner.apply(yourInstance, {"onCreate":onCreate...}) 
     21// and run sequence on bullet runner 
     22br.runSequence("cml text", bml_xml or CMLSequence); 
     23</listing> 
    1724     */ 
    1825    public class BulletRunner extends ScopeLimitObject 
  • as3/CannonML/trunk/src/org/si/cml/extensions/ScopeLimitObject.as

    r4539 r4548  
    1111     
    1212     
    13     /** <b>Extension of CMLObject</b> that scope limitation is implemented. <br/> 
     13    /** Extension of CMLObject that implements scope limitation. <br/> 
    1414     *  You have to call ScopeLimitObject.initialize() first, and you have to call CMLObject.update() for each frame.<br/> 
    1515     *  ScopeLimitObject.initialize() registers some user define commands as below, 
     
    4040        public var scopeYmax:Number; 
    4141        /** The availabirity of scope check */ 
    42         public var enableScope:Boolean = true; 
     42        public var scopeEnabled:Boolean = true; 
    4343 
    4444        /** default value of the available scopes range */ 
     
    7777        public function get isEscaped() : Boolean 
    7878        { 
    79             return (enableScope && (y<scopeYmin || x<scopeXmin || y>scopeYmax || x>scopeXmax)); 
     79            return (scopeEnabled && (y<scopeYmin || x<scopeXmin || y>scopeYmax || x>scopeXmax)); 
    8080        } 
    8181         
     
    206206        { 
    207207            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; }); 
    210210            } 
    211211            return CMLObject.initialize(vertical_);