//////////////////////////////////////////////////////////////////////////////// // // 指定MCにダブルクリック通知機能を実装するクラス // //////////////////////////////////////////////////////////////////////////////// //****************************************************************************// // // クラス宣言 // //****************************************************************************// class util.DoubleClick{ //////////////////////////////////////////////////////////////////////////// // // 変数・定数定義 // //////////////////////////////////////////////////////////////////////////// //************************************************************************// // // 通知用メソッド // //************************************************************************// public var one :Function; //シングルクリック時に実行される処理 public var double:Function; //ダブルクリック成功時に実行される処理 //************************************************************************// // // 処理関連 // //************************************************************************// private var targetMC:MovieClip; private var timerID :Number; private var INTERVAL:Number = 500;//ダブルクリック間隔( ミリ秒 ) //////////////////////////////////////////////////////////////////////////// // // public // //////////////////////////////////////////////////////////////////////////// //************************************************************************// // // コンストラクタ // //************************************************************************// public function DoubleClick( targetMC:MovieClip ){ //フィールド設定 this.targetMC = targetMC; //クリックされた場合の処理定義 this.targetMC[ "scope" ] = this; this.targetMC.onPress = this.click; } //************************************************************************// // // 対象MCがクリックされた場合の処理定義 // //************************************************************************// private function click():Void{ //パス設定 this = this[ "scope" ]; var scope:DoubleClick = this; //シングルクリックされたことを通知 this.one( { mc:this.targetMC } ); //ダブルクリック時の処理定義 this.targetMC.onPress = function(){ scope.end( scope ); scope.double( { mc:scope.targetMC } ); //ダブルクリック成功を通知 }; //タイマー開始 this.timerID = setInterval( end, this.INTERVAL, this ); } //************************************************************************// // // 破棄処理 // //************************************************************************// private function end( scope:DoubleClick ):Void{ scope.targetMC.onPress = scope.click; //クリック時の処理 書き換え clearInterval( scope.timerID ); //ループ処理終了 } }