チェンジセット 842

差分発生行の前後
無視リスト:
コミット日時:
2008/07/14 14:36:22 (4 年前)
コミッタ:
mzp
ログメッセージ:

ちょっとコードを整理した

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • air/ByteCodeDisassembler/Controller.as

    r841 r842  
    1212        public var frame : Array  = []; 
    1313        public var info  : Object = []; 
    14         public var onUpdateTree : Function; 
    15         public var onUpdatePanel : Function; 
     14        private var onLoad   : Array = []; 
     15        private var onInfo     : Array = []; 
     16        private var onProgress : Array = []; 
     17         
     18        private var stream : URLStream; 
     19         
     20        // -------------------- 
     21        //event handler 
     22        // -------------------- 
     23        /** 
     24         * SWFがロードされたときに呼び出されるリスナの追加。 
     25         * 削除はできない。 
     26         */ 
     27        public function addLoadListener(f : Function):void{ 
     28            this.onLoad.push(f); 
     29        } 
    1630 
    17         private var stream : URLStream; 
     31        /** 
     32         * 表示する情報が更新されたときに呼び出されるリスナの追加。 
     33         * 削除はできない。 
     34         */ 
     35        public function addInfoListener(f : Function):void{ 
     36            this.onInfo.push(f); 
     37        } 
     38 
     39        /** 
     40         * ロード等の進捗状況が更新されたときに呼び出されるリスナの追加。 
     41         * 削除はできない。 
     42         */ 
     43        public function addProgressListener(f : Function):void{ 
     44            this.onProgress.push(f); 
     45        } 
     46 
     47         
     48        // リスナの呼び出し 
     49        private function notify(xs : Array):void{ 
     50            for(var i:int = 0; i < xs.length; i++){ 
     51                var f: Function = xs[i]; 
     52                f(this); 
     53            } 
     54        } 
     55 
     56        /** 
     57         * SWFの逆アセンブル。 
     58         */ 
    1859        public function disassemble(path : String) : void{ 
    1960            stream = new URLStream(); 
    2061            stream.addEventListener(Event.COMPLETE, onComplete); 
    21             stream.addEventListener(IOErrorEvent.IO_ERROR, onIOError); 
    2262 
    2363            var req:URLRequest = new URLRequest(path); 
     
    4181                    } 
    4282                    switch (tag) { 
    43                     case 82: { 
    44                         frame.push({label:'abc',tag:'abc',children:[ 
    45                                                                     1,2,3 
    46                                                                     ]}); 
     83                    case 82:  
     84                        frame.push({label:'abc',tag:'abc'}); 
    4785                        swf.seek(length); 
    48                     } 
    4986                        break; 
    5087                         
    51                     default: { 
     88                    default: 
    5289                        frame.push({label:'???',tag:tag,length:length}); 
    5390                        swf.seek(length); 
    54                     } 
    5591                        break; 
    5692                    } 
     
    6197                trace(e); 
    6298            } 
    63             this.onUpdateTree(); 
    64         } 
    65  
    66         private function onIOError() : void{ 
     99            this.notify(this.onLoad); 
    67100        } 
    68101 
    69102        public function showInfo(item : Object):void{ 
    70             //      if(item.label == '???'){ 
    71103            this.info = item; 
    72             //      } 
    73             this.onUpdatePanel(); 
     104            this.notify(this.onInfo); 
    74105        } 
    75106    } 
  • air/ByteCodeDisassembler/Main.mxml

    r835 r842  
    1010 
    1111private function init() : void{ 
    12   var self : Object = this; 
    13   controller.onUpdateTree = function() : void{ 
    14     self.tree.dataProvider = controller.frame; 
    15   }
     12    var self : Object = this; 
     13    controller.addLoadListener(function() : void{ 
     14           self.tree.dataProvider = controller.frame; 
     15       })
    1616 
    17   controller.onUpdatePanel = function() : void{ 
    18     trace('update'); 
    19     switch(controller.info.tag){ 
    20     case 'abc': 
    21         self.abc.visible = true; 
    22         self.etc.visible = false
    23         break; 
    24     default: 
    25         self.abc.visible = false; 
    26         self.etc.visible = true
    27         self.etc_tag.text = controller.info.tag
    28         self.etc_length.text = controller.info.length
    29     } 
    30   } 
     17    controller.addInfoListener(function() : void{ 
     18            switch(controller.info.tag){ 
     19            case 'abc': 
     20                self.abc.visible = true; 
     21               self.etc.visible = false; 
     22               break
     23            default: 
     24                self.abc.visible = false; 
     25               self.etc.visible = true; 
     26               self.etc_tag.text = controller.info.tag
     27               self.etc_length.text = controller.info.length
     28               break
     29           } 
     30        }); 
    3131} 
    3232    ]]>