home *** CD-ROM | disk | FTP | other *** search
/ Champak 108 / jogo-disk-108.iso / Games / goal_2.swf / scripts / DefineSprite_349 / frame_1 / DoAction.as
Text File  |  2010-05-15  |  5KB  |  172 lines

  1. function set_scroll_bar(c_content_height)
  2. {
  3.    function drager_release()
  4.    {
  5.       start_drage = false;
  6.    }
  7.    function up_release()
  8.    {
  9.       d_out = true;
  10.    }
  11.    function down_release()
  12.    {
  13.       u_out = true;
  14.    }
  15.    function drage_drager()
  16.    {
  17.       drager_pos.current = drager_mc._y - drager_pos.strat;
  18.       target = drager_pos.current / axis_bar.height * axis_track.height;
  19.       mc._y -= (mc._y - target) / fiction;
  20.    }
  21.    function drager_down()
  22.    {
  23.       if(d_out)
  24.       {
  25.          scrolll_speed *= btn_scroll_fiction;
  26.       }
  27.       if(drager_mc._y > drager_pos.strat)
  28.       {
  29.          if(scrolll_speed > 0.001)
  30.          {
  31.             drager_mc._y -= scrolll_speed;
  32.          }
  33.       }
  34.    }
  35.    function drager_up()
  36.    {
  37.       if(u_out)
  38.       {
  39.          scrolll_speed *= btn_scroll_fiction;
  40.       }
  41.       if(drager_mc._y < axis_bar.local_y)
  42.       {
  43.          if(scrolll_speed > 0.001)
  44.          {
  45.             drager_mc._y += scrolll_speed;
  46.          }
  47.       }
  48.    }
  49.    function barBg_mc_hit()
  50.    {
  51.       if(drager_mc._y >= drager_pos.strat and drager_mc._y <= axis_bar.local_y)
  52.       {
  53.          drager_mc._y -= (drager_mc._y - mouse_target) / fiction;
  54.       }
  55.       if(drager_mc._y > axis_bar.local_y)
  56.       {
  57.          drager_mc._y = axis_bar.local_y;
  58.       }
  59.       if(drager_mc._y < drager_pos.strat)
  60.       {
  61.          drager_mc._y = drager_pos.strat;
  62.       }
  63.    }
  64.    function hide_scroll_bar()
  65.    {
  66.       up_btn._alpha = drager_mc._alpha = down_btn._alpha = barBg_mc._alpha = 0;
  67.       up_btn.enabled = drager_mc.enabled = down_btn.enabled = barBg_mc.enabled = false;
  68.    }
  69.    function show_scroll_bar()
  70.    {
  71.       up_btn._alpha = drager_mc._alpha = down_btn._alpha = barBg_mc._alpha = 100;
  72.       up_btn.enabled = drager_mc.enabled = down_btn.enabled = barBg_mc.enabled = true;
  73.    }
  74.    function clea_up(_this)
  75.    {
  76.       removeMovieClip(_this.timer_1);
  77.       removeMovieClip(drager_mc.timer);
  78.    }
  79.    clea_up(this);
  80.    myspeed = 1;
  81.    fiction = 10;
  82.    btn_scroll_fiction = 0.9;
  83.    mc._y = mask._y = 0;
  84.    drager_mc._y = barBg_mc._y;
  85.    drager_mc._x = barBg_mc._x;
  86.    scrolll_speed = myspeed;
  87.    if(!c_content_height)
  88.    {
  89.       content_height = mc._height;
  90.    }
  91.    else
  92.    {
  93.       content_height = c_content_height;
  94.    }
  95.    if(content_height < mask._height)
  96.    {
  97.       hide_scroll_bar();
  98.    }
  99.    else
  100.    {
  101.       show_scroll_bar();
  102.    }
  103.    mc.setMask(mask);
  104.    mc_pos = {strat:mask._y,current:0};
  105.    axis_track = {height:mask._y - content_height + this.mask._height};
  106.    drager_pos = {strat:barBg_mc._y,current:0};
  107.    axis_bar = {height:barBg_mc._height - drager_mc._height,local_y:barBg_mc._y + barBg_mc._height - drager_mc._height};
  108.    drager_mc.onPress = function()
  109.    {
  110.       var different;
  111.       removeMovieClip(this._parent.timer_1);
  112.       start_drage = true;
  113.       this.createEmptyMovieClip("timer",0);
  114.       different = _ymouse - drager_mc._y;
  115.       this.timer.onEnterFrame = function()
  116.       {
  117.          drage_drager();
  118.          if(start_drage)
  119.          {
  120.             if(drager_mc._y >= drager_pos.strat and drager_mc._y <= axis_bar.local_y)
  121.             {
  122.                drager_mc._y = _ymouse - different;
  123.             }
  124.             if(drager_mc._y < drager_pos.strat)
  125.             {
  126.                drager_mc._y = drager_pos.strat;
  127.             }
  128.             if(drager_mc._y > axis_bar.local_y)
  129.             {
  130.                drager_mc._y = axis_bar.local_y;
  131.             }
  132.          }
  133.       };
  134.    };
  135.    drager_mc.onRelease = drager_mc.onReleaseOutside = drager_release;
  136.    up_btn.onPress = function()
  137.    {
  138.       d_out = false;
  139.       scrolll_speed = myspeed;
  140.       this._parent.createEmptyMovieClip("timer_1",1);
  141.       this._parent.timer_1.onEnterFrame = function()
  142.       {
  143.          drager_down();
  144.          drage_drager();
  145.       };
  146.    };
  147.    down_btn.onPress = function()
  148.    {
  149.       u_out = false;
  150.       scrolll_speed = myspeed;
  151.       this._parent.createEmptyMovieClip("timer_1",1);
  152.       this._parent.timer_1.onEnterFrame = function()
  153.       {
  154.          drager_up();
  155.          drage_drager();
  156.       };
  157.    };
  158.    up_btn.onRelease = up_btn.onReleaseOutside = up_release;
  159.    down_btn.onRelease = down_btn.onReleaseOutside = down_release;
  160.    barBg_mc.onPress = function()
  161.    {
  162.       mouse_target = _ymouse;
  163.       this._parent.createEmptyMovieClip("timer_1",1);
  164.       this._parent.timer_1.onEnterFrame = function()
  165.       {
  166.          barBg_mc_hit();
  167.          drage_drager();
  168.       };
  169.    };
  170. }
  171. set_scroll_bar(c_content_height);
  172.