差分発生行の前後
無視リスト:
コミット日時:
2008/10/02 01:05:50 (4 年前)
コミッタ:
t-kis
ログメッセージ:

重複定義の削除

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/WindowResize/net/tkis/utils/WindowResize.as

    r1469 r1470  
    55 * 
    66 * @authorTAKEISHI Shun-ichi (T-kis.net) 
    7  * @version1.10 
     7 * @version1.11 
    88 
    99 * 変更履歴 
     
    1212 * 1.02 08.09.27 アニメーションをTween クラスに変更。 
    1313 * 1.10 08.09.29 センタリング対応・対象オブジェをMovieClipからDisplayObjectへ。 
    14  * 1.101 08.10.01 綴り間違え修正 
     14 * 1.11  08.10.01 重複したコードを削除 
    1515 
    1616  
     
    2828 
    2929                /*初期設定値 */ 
    30                 var stagemin_w:int = 600;                                              //コンテンツ最小サイズ横幅 
    31                 var stagemin_h:int = 480;                                              //コンテンツ最小サイズ縦幅 
    32                 var speed:Number = 0.7;                                                        //移動完了までの時間 
    33                 var tweeneasing:Function = Regular.easeOut;            //イージングのタイプ 
     30                var stagemin_w:int=600;//コンテンツ最小サイズ横幅 
     31                var stagemin_h:int=480;//コンテンツ最小サイズ縦幅 
     32                var speed:Number=2;//移動完了までの時間 
     33                var tweeneasing:Function=Regular.easeOut;//イージングのタイプ 
    3434 
    3535                /*その他変数*/ 
    3636                private var move_mc:DisplayObject; 
    3737                private var position_st:String; 
    38                 private var for_x:uint = 0; 
    39                 private var for_y:uint = 0; 
     38                private var for_x:uint=0; 
     39                private var for_y:uint=0; 
    4040                var mc_TweenX:Tween; 
    4141                var mc_TweenY:Tween; 
     
    4646                /*コンストラクタ*/ 
    4747                function WindowResize(movemc:DisplayObject,position:String):void { 
    48                         position_st = position; 
    49                         move_mc = movemc; 
    50                         move_mc.stage.scaleMode = StageScaleMode.NO_SCALE; 
     48                        position_st=position; 
     49                        move_mc=movemc; 
     50                        move_mc.stage.scaleMode=StageScaleMode.NO_SCALE; 
    5151                        fixPosition(); 
    52                         move_mc.stage.addEventListener(Event.RESIZE,onWindowResize); 
    53                 } 
    54                 function onWindowResize(evnet:Event):void { 
    55                         move_mc.stage.addEventListener(Event.ENTER_FRAME,setPosition); 
     52                        move_mc.stage.addEventListener(Event.RESIZE,setPosition); 
    5653                } 
    5754                function setPosition(evnet:Event):void { 
    58                         w = move_mc.stage.stageWidth; 
    59                         h = move_mc.stage.stageHeight; 
     55                        w=move_mc.stage.stageWidth; 
     56                        h=move_mc.stage.stageHeight; 
    6057                        switch (position_st) { 
    6158                                case "right_top" : 
    62                                         for_x= Math.max(stagemin_w-move_mc.width,w-move_mc.width); 
    63                                         mc_TweenX = new Tween(move_mc, "x", tweeneasing, move_mc.x,for_x ,speed, true); 
     59                                        for_x=Math.max(stagemin_w - move_mc.width,w - move_mc.width); 
    6460                                        break; 
    6561                                case "right_center" : 
    66                                         for_x =Math.max(stagemin_w-move_mc.width,w-move_mc.width); 
    67                                         for_y =Math.max(stagemin_h/2-move_mc.height/2,h/2-move_mc.height/2); 
    68                                         mc_TweenX = new Tween(move_mc, "x", tweeneasing, move_mc.x,for_x ,speed, true); 
    69                                         mc_TweenY = new Tween(move_mc, "y", tweeneasing, move_mc.y,for_y ,speed, true); 
     62                                        for_x=Math.max(stagemin_w - move_mc.width,w - move_mc.width); 
     63                                        for_y=Math.max(stagemin_h / 2 - move_mc.height / 2,h / 2 - move_mc.height / 2); 
     64 
    7065                                        break; 
    7166                                case "right_bottom" : 
    72                                         for_x =Math.max(stagemin_w-move_mc.width,w-move_mc.width); 
    73                                         for_y =Math.max(stagemin_h-move_mc.height,h-move_mc.height); 
    74                                         mc_TweenX = new Tween(move_mc, "x", tweeneasing, move_mc.x,for_x ,speed, true); 
    75                                         mc_TweenY = new Tween(move_mc, "y", tweeneasing, move_mc.y,for_y ,speed, true); 
     67                                        for_x=Math.max(stagemin_w - move_mc.width,w - move_mc.width); 
     68                                        for_y=Math.max(stagemin_h - move_mc.height,h - move_mc.height); 
    7669                                        break; 
    7770                                case "center_top" : 
    78                                         for_x =Math.max(stagemin_w/2-move_mc.width/2,w/2-move_mc.width/2); 
    79                                         mc_TweenX = new Tween(move_mc, "x", tweeneasing, move_mc.x,for_x ,speed, true); 
     71                                        for_x=Math.max(stagemin_w / 2 - move_mc.width / 2,w / 2 - move_mc.width / 2); 
    8072                                        break; 
    8173                                case "center_center" : 
    82                                         for_x =Math.max(stagemin_w/2-move_mc.width/2,w/2-move_mc.width/2); 
    83                                         for_y =Math.max(stagemin_h/2-move_mc.height/2,h/2-move_mc.height/2); 
    84                                         mc_TweenX = new Tween(move_mc, "x", tweeneasing, move_mc.x,for_x ,speed, true); 
    85                                         mc_TweenY = new Tween(move_mc, "y", tweeneasing, move_mc.y,for_y ,speed, true); 
     74                                        for_x=Math.max(stagemin_w / 2 - move_mc.width / 2,w / 2 - move_mc.width / 2); 
     75                                        for_y=Math.max(stagemin_h / 2 - move_mc.height / 2,h / 2 - move_mc.height / 2); 
    8676                                        break; 
    8777                                case "center_bottom" : 
    88                                         for_x =Math.max(stagemin_w/2-move_mc.width/2,w/2-move_mc.width/2); 
    89                                         for_y =Math.max(stagemin_h-move_mc.height,h-move_mc.height); 
    90                                         mc_TweenX = new Tween(move_mc, "x", tweeneasing, move_mc.x,for_x ,speed, true); 
    91                                         mc_TweenY = new Tween(move_mc, "y", tweeneasing, move_mc.y,for_y ,speed, true); 
     78                                        for_x=Math.max(stagemin_w / 2 - move_mc.width / 2,w / 2 - move_mc.width / 2); 
     79                                        for_y=Math.max(stagemin_h - move_mc.height,h - move_mc.height); 
    9280                                        break; 
    9381                                case "left_top" : 
    9482                                        break; 
    9583                                case "left_center" : 
    96                                         for_y =Math.max(stagemin_h/2-move_mc.height/2,h/2-move_mc.height/2); 
    97                                         mc_TweenY = new Tween(move_mc, "y", tweeneasing, move_mc.y,for_y ,speed, true); 
     84                                        for_y=Math.max(stagemin_h / 2 - move_mc.height / 2,h / 2 - move_mc.height / 2); 
    9885                                        break; 
    9986                                case "left_bottom" : 
    100                                         for_y = Math.max(stagemin_h-move_mc.height,h-move_mc.height); 
    101                                         mc_TweenY = new Tween(move_mc, "y", tweeneasing, move_mc.y,for_y ,speed, true); 
     87                                        for_y=Math.max(stagemin_h - move_mc.height,h - move_mc.height); 
    10288                                        break; 
    10389                        } 
    104                         if (Math.abs(for_y-move_mc.y) < 1 && Math.abs(for_x-move_mc.x) < 1 ) { 
    105                                 move_mc.stage.removeEventListener(Event.ENTER_FRAME,setPosition); 
    106                                 fixPosition(); 
    107                         } 
     90                        mc_TweenX=new Tween(move_mc,"x",tweeneasing,move_mc.x,for_x,speed,true); 
     91                        mc_TweenY=new Tween(move_mc,"y",tweeneasing,move_mc.y,for_y,speed,true); 
    10892                } 
    10993                function fixPosition():void { 
    110                         w = move_mc.stage.stageWidth; 
    111                         h = move_mc.stage.stageHeight; 
     94                        w=move_mc.stage.stageWidth; 
     95                        h=move_mc.stage.stageHeight; 
    11296                        switch (position_st) { 
    11397                                case "right_top" : 
    114                                         move_mc.x =Math.max(stagemin_w-move_mc.width,w-move_mc.width); 
    115                                         move_mc.y =0; 
     98                                        move_mc.x=Math.max(stagemin_w - move_mc.width,w - move_mc.width); 
     99                                        move_mc.y=0; 
    116100                                        break; 
    117101                                case "right_center" : 
    118                                         move_mc.x =Math.max(stagemin_w-move_mc.width,w-move_mc.width); 
    119                                         move_mc.y =Math.max(stagemin_h/2-move_mc.height/2,h/2-move_mc.height/2); 
     102                                        move_mc.x=Math.max(stagemin_w - move_mc.width,w - move_mc.width); 
     103                                        move_mc.y=Math.max(stagemin_h / 2 - move_mc.height / 2,h / 2 - move_mc.height / 2); 
    120104                                        break; 
    121105                                case "right_bottom" : 
    122                                         move_mc.x =Math.max(stagemin_w-move_mc.width,w-move_mc.width); 
    123                                         move_mc.y =Math.max(stagemin_h-move_mc.height,h-move_mc.height); 
     106                                        move_mc.x=Math.max(stagemin_w - move_mc.width,w - move_mc.width); 
     107                                        move_mc.y=Math.max(stagemin_h - move_mc.height,h - move_mc.height); 
    124108                                        break; 
    125109                                case "center_top" : 
    126                                         move_mc.x =Math.max(stagemin_w/2-move_mc.width/2,w/2-move_mc.width/2); 
    127                                         move_mc.y =0; 
     110                                        move_mc.x=Math.max(stagemin_w / 2 - move_mc.width / 2,w / 2 - move_mc.width / 2); 
     111                                        move_mc.y=0; 
    128112                                        break; 
    129113                                case "center_center" : 
    130                                         move_mc.x =Math.max(stagemin_w/2-move_mc.width/2,w/2-move_mc.width/2); 
    131                                         move_mc.y =Math.max(stagemin_h/2-move_mc.height/2,h/2-move_mc.height/2); 
     114                                        move_mc.x=Math.max(stagemin_w / 2 - move_mc.width / 2,w / 2 - move_mc.width / 2); 
     115                                        move_mc.y=Math.max(stagemin_h / 2 - move_mc.height / 2,h / 2 - move_mc.height / 2); 
    132116                                        break; 
    133117                                case "center_bottom" : 
    134                                         move_mc.x =Math.max(stagemin_w/2-move_mc.width/2,w/2-move_mc.width/2); 
    135                                         move_mc.y =Math.max(stagemin_h-move_mc.height,h-move_mc.height); 
     118                                        move_mc.x=Math.max(stagemin_w / 2 - move_mc.width / 2,w / 2 - move_mc.width / 2); 
     119                                        move_mc.y=Math.max(stagemin_h - move_mc.height,h - move_mc.height); 
    136120                                        break; 
    137121                                case "left_top" : 
    138                                         move_mc.x =0; 
    139                                         move_mc.y =0; 
     122                                        move_mc.x=0; 
     123                                        move_mc.y=0; 
    140124                                        break; 
    141125                                case "left_center" : 
    142                                         move_mc.x =0; 
    143                                         move_mc.y =Math.max(stagemin_h/2-move_mc.height/2,h/2-move_mc.height/2); 
     126                                        move_mc.x=0; 
     127                                        move_mc.y=Math.max(stagemin_h / 2 - move_mc.height / 2,h / 2 - move_mc.height / 2); 
    144128                                        break; 
    145129                                case "left_bottom" : 
    146                                         move_mc.x =0; 
    147                                         move_mc.y =Math.max(stagemin_h-move_mc.height,h-move_mc.height); 
     130                                        move_mc.x=0; 
     131                                        move_mc.y=Math.max(stagemin_h - move_mc.height,h - move_mc.height); 
    148132                                        break; 
    149133                        }