チェンジセット 231

差分発生行の前後
無視リスト:
コミット日時:
2008/02/05 17:15:17 (4 年前)
コミッタ:
fladdict
ログメッセージ:

--

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/Commands/src/AsyncCommand.as

    r200 r231  
    55         
    66        /** 
    7          * データのロードやアニメーション等、非同期の処理を行う場合のコマンド 
    8          * 引数にイベントを追加できる。 
     7         * Executes async function call. E.G. Loader, URLLoader, etc... 
     8         * This Command register functions event dispacher and catch their event. 
     9         * After complete command, this dispaches Event.COMPLETE 
    910         *  
    10          * URLLoader等の非同期な機能に対してコマンドを実行できる。 
     11         * @usage 
     12         *  
     13         * var loader:URLLoader = new URLLoader(); 
     14         * var command:ICommand = new AsyncCommand(loader, loader.load, [new URLRequest(url);], loader.loaderContent, Event.COMPLETE); 
     15         * command.addEventListener(Event.COMPLETE, _comandCompleteHandler); 
     16         * command.execute(); 
    1117         */ 
    1218        public class AsyncCommand extends Command 
     
    1622                 
    1723                /** 
    18                  * @param thisObject thisスコープとなるオブジェクト 
    19                  * @param func 実行される関数 
    20                  * @param eventDispatcher 関数の処理の完了を通知するイベント発行者 
    21                  * @param 終了通知のイベントのタイプ 
     24                 * @param thisObject Scpoe used as This 
     25                 * @param func Function for execute 
     26                 * @param EventDispatcher Object that dispaches functions complete event. 
     27                 * @param Type of Event for EventDispatcher. 
    2228                 */ 
    2329                public function AsyncCommand(thisObject:Object, func:Function, params:Array, eventDispatcher:EventDispatcher, eventType:String) 
     
    3743                protected function executeCompleteHandler( e:Event ):void 
    3844                { 
    39                         //_eventDispatcher.removeEventListener(_eventType, onExecute); 
     45                        _eventDispatcher.removeEventListener(_eventType, executeCompleteHandler); 
    4046                        this.dispatchComplete(); 
    4147                } 
  • as3/Commands/src/Command.as

    r203 r231  
    22{ 
    33        /** 
    4          * Executes passed function, when execute() is called. 
    5          * After execution, this dispaches Event.COMPLETE. 
     4         * 関数execute()をコールすることで、あらかじめ登録しておいた処理を実行します。 
     5         * 処理の終了後にはEvent.COMPLETEが発行されます。 
    66         *  
    7          * @usage 
     7         * Commandクラスの現状の課題は、インスタンスの作成時の段階で、 
     8         * 関数およびパラメーターが存在していなければならないことです。 
     9         * 将来的には関数、パラメーターに対して遅延評価を行うことのできる仕組みを実装する予定です。 
    810         *  
    9          * var com : Command = new Command( null, trace, ["hellow world"] ); 
    10          * com.execute(); 
     11         * @example 以下はCommandクラスの基本的な使い方です。 
     12         * <listing version="3.0"> 
     13         * var command:Command = new Command(null, trace, [""]); 
     14         * command.execute(); 
     15         * </listing> 
    1116         *  
    1217         */ 
     
    1823                 
    1924                /** 
    20                  * @param thisObject:Object Scope that is used as "this" 
    21                  * @param func:Function Function will be executed 
    22                  * @param params:Array Parameters will be passed to function 
     25                 * 関数execute()実行時に行いたい処理を登録します。 
     26                 *  
     27                 * @param thisObject Thisとして使用されるスコープです。AS3では指定する必要はありません。AS2との互換性の為に存在しています。 
     28                 * @param func:Function 登録したい関数の参照。 
     29                 * @param params:Array 関数実行時に渡されるパラメーター 
    2330                 */ 
    2431                public function Command(thisObject:Object, func:Function, params:Array=null) 
     
    3037                } 
    3138                 
     39                 
     40                /** 
     41                 * コンストラクタで登録した処理を実行します。 
     42                 *  
     43                 * @eventType Event.COMPLETE 
     44                 */ 
    3245                override public function execute():void 
    3346                { 
  • as3/Commands/src/CommandBase.as

    r203 r231  
    55         
    66        /** 
    7          * Abstract class for all commands package. 
     7         * commandsパッケージで使用されるコマンドのルートとなる抽象クラス。 
     8         * 独自のコマンドクラスを作成する場合には、基本的にこのクラスを継承してください。 
    89         */ 
    910        public class CommandBase extends EventDispatcher implements ICommand 
    1011        { 
    1112                /** 
    12                  * Template function. 
     13                 * テンプレート関数。 
    1314                 *  
    14                  * Simply override this function with your own processing, after call dispatchComplete() function. 
     15                 * この関数をオーバーライドして実行したい処理を書きます。 
     16                 * 同期処理、非同期処理にかかわらず、処理の終了時には関数dispatchComplete()をコールしてください。 
    1517                 */ 
    1618                public function execute():void{} 
    1719                 
    1820                 
    19                 //cancel commands 
     21                /** 
     22                 * テンプレート関数。 
     23                 *  
     24                 * この関数は将来の拡張の為に予約されています。 
     25                 */ 
    2026                public function cancel():void{} 
    2127                 
    2228                 
    2329                /** 
    24                  * dispatches event after command completation. 
     30                 * コマンドの終了を通知する為に、Event.COMPLETEを発行します。 
    2531                 */ 
    2632                protected function dispatchComplete():void 
  • as3/Commands/src/ICommand.as

    r203 r231  
    33         
    44        /** 
    5          * Interface for Command Library 
    6          *  
    7          * C A U T I O N 
    8          * After command execution, you must dispatch Event.COMPLETE 
     5         * commandsライブラリで使用される共通インターフェース。 
    96         */ 
    107        public interface ICommand 
     
    2522                                                                                ):void 
    2623                 
     24                /** 
     25                 * @eventType Event.COMPLETE 同期、非同期に関わらずexecuteによって行われる処理の終了時にEvent.Completeイベントを発行してください。 
     26                 */ 
    2727                function execute():void 
    2828        } 
  • as3/Commands/src/ParallelCommand.as

    r203 r231  
    44         
    55        /** 
    6          * コマンドを同時に実行し、全てが終了したらCompleteイベントを発行する。 
    7          * 複数のデータロード、インスタンス初期化などの待ちに使う。 
     6         * Executes series of commands at once, and wait for all complement. 
     7         * After execution, this dispatches Event.COMPLETE. 
     8         * Used for multiple data loading. 
    89         *  
    910         * var coms : Array = [ 
     
    1314         *  
    1415         * var pCom : ParallelCommand = new ParallelCommand( coms ); 
     16         * pCom.addEventListener(Event.COMPLETE, _commandCompleteHandler); 
    1517         * pCom.execute(); 
    1618         *  
    1719         */ 
    18         public class ParallelCommand extends CommandBase 
     20        public class ParallelCommand extends BatchCommand 
    1921        { 
    20                 protected var _commands:Array 
    21                 protected var _index:Number 
    22                  
    23                 public function ParallelCommand( commandArray:Array ):void 
     22                public function ParallelCommand( commandArray:Array ) 
    2423                { 
    25                         super(); 
    26                          
    27                         _index = 0; 
    28                         _commands = commandArray.concat(); 
     24                        super( commandArray ); 
    2925                } 
    3026                 
    3127                 
    32                 public function push(com:ICommand):void 
    33                 { 
    34                         _commands.push(com); 
    35                 } 
     28                 
    3629                 
    3730                 
  • as3/Commands/src/SerialCommand.as

    r203 r231  
    44         
    55        /** 
    6          * 登録したコマンドを順番に実行し、全て実行したらCompleteイベントを発行する 
     6         * 登録された複数のコマンドを1つづつ順番に実行、終了させていきます。 
     7         * 最後のコマンドの終了時にEvent.COMPLETEを発行します。 
    78         *  
    8          * @usage 
     9         * SerialCommandインスタンスは1回だけの使用を前提とし、再利用は考慮されていません。 
     10         * 同じ処理を繰り返して行いたい場合には、処理の度に新しいSerialCommandインスタンスを作成してください。 
    911         *  
    10          * var coms : Array = [ 
     12         * @example 以下のコードは、hello と表示し、1秒後に world と表示します。 
     13         * <listing version="3.0"> 
     14         * var ar : Array = [ 
    1115         *              new Command("hello"), 
    1216         *              new WaitCommand(1000), 
    1317         *              new Command("world")]; 
    1418         *  
    15          * var sCom : SerialCommand = new SerialCommand( coms ); 
     19         * var sCom : SerialCommand = new SerialCommand( ar ); 
     20         * sCom.addEventListener(Event.COMPLETE, _commandExecuteHandler); 
    1621         * sCom.execute(); 
     22         * </listing> 
    1723         *  
    1824         */ 
    19         public class SerialCommand extends CommandBase 
     25        public class SerialCommand extends BatchCommand 
    2026        { 
    21                 protected var _index:Number 
    22                 protected var _commands:Array 
    23                  
     27                /** 
     28                * @param comamndArray ICommandインターフェースを実装したコマンドの配列。 
     29                */ 
    2430                public function SerialCommand( commandArray:Array ) 
    2531                { 
    26                         super(); 
    27                          
    28                         _index = 0; 
    29                         _commands = commandArray.concat(); 
    30                 } 
    31                  
    32                 public function push(com:ICommand):void 
    33                 { 
    34                         _commands.push(com); 
     32                        super(commandArray); 
    3533                } 
    3634                 
     
    4240                 
    4341                 
     42                //内部的に次のコマンドを実行 
    4443                protected function doNext():void 
    4544                { 
     
    5049                 
    5150                 
     51                //子コマンドが終了したときのハンドラ 
    5252                protected function doNextCompleteHandler( e:Event ):void 
    5353                { 
    54                         var c :ICommand = ICommand(e.target); 
    55                         c.removeEventListener(Event.COMPLETE, doNextCompleteHandler); 
    56                          
     54                        e.target.removeEventListener(e.type, arguments.callee); 
     55 
    5756                        _index ++; 
    5857                         
  • as3/Commands/src/ext/LoaderCommand.as

    r211 r231  
    66        import flash.net.URLRequest; 
    77        import flash.display.Loader; 
     8        import flash.events.IOErrorEvent; 
    89 
    910        /* 
     
    1415        request:URLRequest 
    1516        urlScope:Object, urlProp:String 
     17         
     18        alternativeURL:String 代替イメージのURL 
    1619         
    1720        loader:Loader 
     
    3336                        loader = this.buildLoader(); 
    3437                        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _completeHandler, false, 0, true); 
     38                        loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _ioErrorHandler, false, 0, true); 
    3539                         
    3640                        loader.load(req); 
     
    4246                { 
    4347                        loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, _completeHandler); 
     48                        loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, _ioErrorHandler); 
    4449                         
    4550                        paramObj = null; 
    4651                        loader = null; 
    4752                        this.dispatchComplete();         
     53                } 
     54                 
     55                protected function _ioErrorHandler(e:Event):void 
     56                { 
     57                        trace("irerror", paramObj.url); 
     58                        if(paramObj.alternativeURL){ 
     59                                loader.load(new URLRequest(paramObj.alternativeURL)); 
     60                        }else{ 
     61                                _completeHandler(e); 
     62                        } 
    4863                } 
    4964