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

  1. class application.screens.AbstractScreen extends MovieClip
  2. {
  3.    var log;
  4.    var configObj;
  5.    var systemObj;
  6.    var dataObj;
  7.    var hasFocus;
  8.    var controller;
  9.    var focusBorder;
  10.    var onRollOver;
  11.    var onRollOut;
  12.    var onPress;
  13.    var IvId;
  14.    var IvID;
  15.    var onRelease;
  16.    var onReleaseOutside;
  17.    var tabId;
  18.    var focusManager;
  19.    var offset;
  20.    var rootMC;
  21.    function AbstractScreen()
  22.    {
  23.       super();
  24.       this.log = application.debug.Logging.getInstance();
  25.       this.log.addKey("abstractScreen",65535);
  26.    }
  27.    function setConfigProvider(configObj)
  28.    {
  29.       this.configObj = configObj;
  30.    }
  31.    function setSystemProvider(systemObj)
  32.    {
  33.       this.systemObj = systemObj;
  34.    }
  35.    function setDataObj(dataObj)
  36.    {
  37.       this.dataObj = dataObj;
  38.    }
  39.    function buildButton(mc)
  40.    {
  41.       this.log.showKeyedMessage("abstractScreen","buildButton " + mc);
  42.       mc.enabled = true;
  43.       mc.controller = this;
  44.       mc.gotoAndStop(1);
  45.       mc.focusManager = application.core.FocusManager.getInstance();
  46.       mc.focusBorder = application.ui.FocusBorder.getInstance();
  47.       mc.createEmptyMovieClip("rect",100);
  48.       mc.rect._visible = false;
  49.       mc.tabEnabled = false;
  50.       mc.hasFocus = false;
  51.       mc.onRollOver = function()
  52.       {
  53.          if(this.enabled && !this.hasFocus)
  54.          {
  55.             this.gotoAndStop(2);
  56.             this.controller.onButtonRollOver(this);
  57.          }
  58.       };
  59.       mc.onRollOut = function()
  60.       {
  61.          if(this.enabled && !this.hasFocus)
  62.          {
  63.             this.gotoAndStop(1);
  64.             this.controller.onButtonRollOut(this);
  65.          }
  66.       };
  67.       mc.onPress = function()
  68.       {
  69.          if(this.enabled)
  70.          {
  71.             this.gotoAndStop(3);
  72.             this.controller.onButtonPress(this);
  73.          }
  74.       };
  75.       mc.onRelease = function()
  76.       {
  77.          if(this.enabled)
  78.          {
  79.             application.core.FocusManager.getInstance().switchFocus(this);
  80.             _global.SoundManager.playSound();
  81.             this.gotoAndStop(2);
  82.             this.controller.onButtonRelease(this);
  83.          }
  84.       };
  85.       mc.onReleaseOutside = function()
  86.       {
  87.          if(this.enabled)
  88.          {
  89.             this.gotoAndStop(1);
  90.             this.controller.onButtonReleaseOutside(this);
  91.          }
  92.       };
  93.       mc.onDisable = function()
  94.       {
  95.          this.enabled = false;
  96.          this.gotoAndStop(4);
  97.          if(this.hasFocus)
  98.          {
  99.             this.hasFocus = false;
  100.             this.focusBorder.hide();
  101.          }
  102.          this.controller.onButtonDisable(this);
  103.       };
  104.       mc.onEnable = function()
  105.       {
  106.          this.enabled = true;
  107.          this.gotoAndStop(1);
  108.          this.controller.onButtonEnable(this);
  109.       };
  110.       mc.onSetFocus = function()
  111.       {
  112.          this.onRollOver();
  113.          this.hasFocus = true;
  114.          this.focusBorder.showBorder(this);
  115.       };
  116.       mc.onKillFocus = function()
  117.       {
  118.          this.hasFocus = false;
  119.          this.onRollOut();
  120.          this.focusBorder.hide();
  121.       };
  122.       mc.onSelect = function()
  123.       {
  124.          this.onPress();
  125.          if(this.IvId != undefined)
  126.          {
  127.             clearInterval(this.IvID);
  128.             delete this.IvID;
  129.          }
  130.          this.IvID = setInterval(this,"onDeselect",100);
  131.       };
  132.       mc.onDeselect = function()
  133.       {
  134.          clearInterval(this.IvID);
  135.          delete this.IvID;
  136.          if(this.hasFocus)
  137.          {
  138.             this.onRelease();
  139.          }
  140.          else
  141.          {
  142.             this.onReleaseOutside();
  143.          }
  144.       };
  145.       mc.onUnload = function()
  146.       {
  147.          this.focusManager.unregister(this.tabId,this);
  148.       };
  149.    }
  150.    function buildToggle(mc)
  151.    {
  152.       this.log.showKeyedMessage("abstractScreen","buildToggle " + mc);
  153.       mc.enabled = true;
  154.       mc.controller = this;
  155.       mc.gotoAndStop(1);
  156.       mc.focusManager = application.core.FocusManager.getInstance();
  157.       mc.focusBorder = application.ui.FocusBorder.getInstance();
  158.       mc.createEmptyMovieClip("rect",100);
  159.       mc.rect._visible = false;
  160.       mc.tabEnabled = false;
  161.       mc.offset = 0;
  162.       mc.hasFocus = false;
  163.       mc.onRollOver = function()
  164.       {
  165.          if(this.enabled && !this.hasFocus)
  166.          {
  167.             this.gotoAndStop(2 + this.offset);
  168.             this.controller.onButtonRollOver(this);
  169.          }
  170.       };
  171.       mc.onRollOut = function()
  172.       {
  173.          if(this.enabled && !this.hasFocus)
  174.          {
  175.             this.gotoAndStop(1 + this.offset);
  176.             this.controller.onButtonRollOut(this);
  177.          }
  178.       };
  179.       mc.onPress = function()
  180.       {
  181.          if(this.enabled)
  182.          {
  183.             this.gotoAndStop(3 + this.offset);
  184.             this.controller.onButtonPress(this);
  185.          }
  186.       };
  187.       mc.onRelease = function()
  188.       {
  189.          if(this.enabled)
  190.          {
  191.             application.core.FocusManager.getInstance().switchFocus(this);
  192.             if(this.offset == 0)
  193.             {
  194.                this.offset = 4;
  195.             }
  196.             else
  197.             {
  198.                this.offset = 0;
  199.             }
  200.             this.gotoAndStop(2 + this.offset);
  201.             this.controller.onButtonRelease(this);
  202.          }
  203.       };
  204.       mc.onReleaseOutside = function()
  205.       {
  206.          if(this.enabled)
  207.          {
  208.             this.gotoAndStop(1 + this.offset);
  209.             this.controller.onButtonReleaseOutside(this);
  210.          }
  211.       };
  212.       mc.onDisable = function()
  213.       {
  214.          this.enabled = false;
  215.          this.gotoAndStop(4 + this.offset);
  216.          if(this.hasFocus)
  217.          {
  218.             this.hasFocus = false;
  219.             this.focusBorder.hide();
  220.          }
  221.          this.controller.onButtonDisable(this);
  222.       };
  223.       mc.onEnable = function()
  224.       {
  225.          this.enabled = true;
  226.          this.gotoAndStop(1 + this.offset);
  227.          this.controller.onButtonEnable(this);
  228.       };
  229.       mc.onSetFocus = function()
  230.       {
  231.          this.onRollOver();
  232.          this.hasFocus = true;
  233.          this.focusBorder.showBorder(this);
  234.       };
  235.       mc.onKillFocus = function()
  236.       {
  237.          this.hasFocus = false;
  238.          this.onRollOut();
  239.          this.focusBorder.hide();
  240.       };
  241.       mc.onSelect = function()
  242.       {
  243.          if(this.hasFocus)
  244.          {
  245.             this.onPress();
  246.             if(this.IvId != undefined)
  247.             {
  248.                clearInterval(this.IvID);
  249.                delete this.IvID;
  250.             }
  251.             this.IvID = setInterval(this,"onDeselect",100);
  252.          }
  253.       };
  254.       mc.onDeselect = function()
  255.       {
  256.          clearInterval(this.IvID);
  257.          delete this.IvID;
  258.          if(this.hasFocus)
  259.          {
  260.             this.onRelease();
  261.          }
  262.          else
  263.          {
  264.             this.onReleaseOutside();
  265.          }
  266.       };
  267.       mc.onUnload = function()
  268.       {
  269.          this.focusManager.unregister(this.tabId,this);
  270.       };
  271.    }
  272.    function setLabel(mc, s, autosize)
  273.    {
  274.       this.log.startFoldMessage("abstractScreen","setLabel " + mc);
  275.       this.log.addToFoldMessage("abstractScreen","");
  276.       this.log.addToFoldMessage("abstractScreen","\t\tBtn=" + mc);
  277.       this.log.addToFoldMessage("abstractScreen","\t\tText=" + s);
  278.       this.log.endFoldMessage("abstractScreen");
  279.       var _loc3_ = mc.label;
  280.       _loc3_.autoSize = autosize;
  281.       _loc3_.text = s;
  282.       if(s.length < 1)
  283.       {
  284.          this.log.showKeyedMessage("abstractScreen","\t*** ERROR *** empty Label in Button " + mc);
  285.       }
  286.    }
  287.    function reszizeButtonBackground(mc, width, height)
  288.    {
  289.       mc._height = height;
  290.       mc._width = width;
  291.    }
  292.    function createFocusRec(mc, w, h, x, y)
  293.    {
  294.       var _loc2_ = mc.rect;
  295.       _loc2_.clear();
  296.       _loc2_.lineStyle(2,this.configObj.tabBorderColor,100);
  297.       _loc2_.moveTo(0,0);
  298.       _loc2_.lineTo(w,0);
  299.       _loc2_.lineTo(w,h);
  300.       _loc2_.lineTo(0,h);
  301.       _loc2_.lineTo(0,0);
  302.       _loc2_._x = x;
  303.       _loc2_._y = y;
  304.    }
  305.    function setContainer(rootMC)
  306.    {
  307.       this.rootMC = rootMC;
  308.    }
  309. }
  310.