home *** CD-ROM | disk | FTP | other *** search
/ T-Online 6 / T-Online.iso / Animation / content / intro / intro.swf / scripts / __Packages / application / screens / ScrollBarScreen.as < prev    next >
Encoding:
Text File  |  2005-10-20  |  3.6 KB  |  115 lines

  1. class application.screens.ScrollBarScreen extends application.screens.AbstractScreen implements application.models.IScreen
  2. {
  3.    var instCounter;
  4.    var scrollbar;
  5.    var startPos;
  6.    var startPosPic;
  7.    var scrollProperties;
  8.    var contentMC;
  9.    var listener;
  10.    function ScrollBarScreen()
  11.    {
  12.       super();
  13.       this.instCounter = 1;
  14.       this.scrollbar = null;
  15.       this.startPos = null;
  16.       this.startPosPic = null;
  17.       this.scrollProperties = {};
  18.       this.scrollProperties.content = {};
  19.       this.scrollProperties.scrollBar = {};
  20.    }
  21.    function setContent(contentMC, viewHeight)
  22.    {
  23.       this.contentMC = contentMC;
  24.       this.startPos = contentMC._y;
  25.       this.startPosPic = contentMC.pic._y;
  26.       this.scrollProperties.content.contentHeight = contentMC._height;
  27.       this.scrollProperties.content.viewHeight = viewHeight;
  28.       this.scrollProperties.content.contentToScroll = this.scrollProperties.content.contentHeight - this.scrollProperties.content.viewHeight;
  29.       this.scrollProperties.content.maxScroll = this.scrollProperties.content.contentToScroll;
  30.       this.scrollProperties.scrollBar.height = viewHeight;
  31.       this.build();
  32.    }
  33.    function getContent()
  34.    {
  35.       return this.contentMC;
  36.    }
  37.    function forceContent(contentMC, height, viewHeight)
  38.    {
  39.       this.contentMC = contentMC;
  40.       this.startPos = contentMC._y;
  41.       this.startPosPic = contentMC.pic._y;
  42.       this.scrollProperties.content.contentHeight = height;
  43.       this.scrollProperties.content.viewHeight = viewHeight;
  44.       this.scrollProperties.content.contentToScroll = this.scrollProperties.content.contentHeight - this.scrollProperties.content.viewHeight;
  45.       this.scrollProperties.content.maxScroll = this.scrollProperties.content.contentToScroll;
  46.       this.scrollProperties.scrollBar.height = viewHeight;
  47.       this.build();
  48.    }
  49.    function build()
  50.    {
  51.       if(this.scrollProperties.content.contentHeight > this.scrollProperties.content.viewHeight)
  52.       {
  53.          if(this.scrollbar == null)
  54.          {
  55.             this.listener = new application.listener.ScrollBarScreenListener();
  56.             this.listener.setHolder(this);
  57.             Object.registerClass("scrollBar",components.ui.scrollbar.ScrollBar);
  58.             this.scrollbar = components.ui.scrollbar.ScrollBar(this.attachMovie("scrollBar","scrollbar",this.instCounter++));
  59.             this.scrollbar.setDataProvider(this.scrollProperties);
  60.             this.scrollbar.init();
  61.             this.scrollbar.build();
  62.             this.scrollbar.addListener(this.listener);
  63.             this.scrollbar.moveTo(721,73);
  64.             Mouse.addListener(this.scrollbar);
  65.          }
  66.          else
  67.          {
  68.             this.scrollbar.update();
  69.          }
  70.       }
  71.       else if(this.scrollbar == null)
  72.       {
  73.          this.scrollbar.removeListener(this.listener);
  74.          this.scrollbar.removeMovieClip();
  75.          this.scrollbar = null;
  76.       }
  77.    }
  78.    function onScroll(pos)
  79.    {
  80.       this.contentMC.pic._y = this.startPosPic + pos;
  81.       this.contentMC._y = this.startPos - pos;
  82.       application.core.FocusManager.getInstance().onScroll();
  83.    }
  84.    function scrollTo(pos)
  85.    {
  86.       var _loc2_ = -1 * (this.contentMC._y + pos);
  87.       this.scrollbar.scrollTo(_loc2_);
  88.    }
  89.    function onButtonRollOver(mc)
  90.    {
  91.    }
  92.    function onButtonRollOut(mc)
  93.    {
  94.    }
  95.    function onButtonPress(mc)
  96.    {
  97.    }
  98.    function onButtonRelease(mc)
  99.    {
  100.    }
  101.    function onButtonDisable(mc)
  102.    {
  103.    }
  104.    function onButtonEnable(mc)
  105.    {
  106.    }
  107.    function onUnload()
  108.    {
  109.       Mouse.removeListener(this.scrollbar);
  110.    }
  111.    function onButtonReleaseOutside(mc)
  112.    {
  113.    }
  114. }
  115.