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

  1. class application.screens.HelpScreen extends application.screens.AbstractScreen implements application.models.IScreen
  2. {
  3.    var instCounter;
  4.    var contentCounter;
  5.    var scrollBar;
  6.    var lastContent;
  7.    var contentHolder;
  8.    var lastTopic;
  9.    var format;
  10.    var format1;
  11.    var contentXML;
  12.    var activeSub;
  13.    var background;
  14.    var configPath;
  15.    var dataObj;
  16.    var topics;
  17.    var container;
  18.    var configObj;
  19.    var rootMC;
  20.    var onEnterFrame;
  21.    function HelpScreen()
  22.    {
  23.       super();
  24.       this.instCounter = 1;
  25.       this.contentCounter = 1;
  26.       this.scrollBar = null;
  27.       this.lastContent = null;
  28.       this.contentHolder = null;
  29.       this.lastTopic = null;
  30.       this.format = new TextFormat();
  31.       this.format.align = "left";
  32.       this.format.color = 0;
  33.       this.format.font = "Tele-GroteskNor";
  34.       this.format.leading = 2;
  35.       this.format.size = 16;
  36.       this.format1 = new TextFormat();
  37.       this.format1.align = "left";
  38.       this.format1.color = 14811252;
  39.       this.format1.font = "Tele-GroteskNor";
  40.       this.format1.leading = 2;
  41.       this.format1.size = 16;
  42.    }
  43.    function onLoadXMLHelp(data)
  44.    {
  45.       this.contentXML = new XML();
  46.       this.contentXML.ignoreWhite = true;
  47.       this.contentXML.parseXML(data);
  48.       this.parseXML();
  49.    }
  50.    function update(activeSub, subContent)
  51.    {
  52.       this.activeSub = activeSub;
  53.       this.lastTopic = null;
  54.       this.contentHolder.removeMovieClip();
  55.       this.background.clear();
  56.       this.background.removeMovieClip();
  57.       this.background = this.createEmptyMovieClip("background" + this.contentCounter,this.instCounter++);
  58.       this.contentHolder = this.createEmptyMovieClip("contentHolder" + this.contentCounter,this.instCounter++);
  59.       this.contentCounter = this.contentCounter + 1;
  60.       var _loc16_ = 20;
  61.       if(subContent == null)
  62.       {
  63.          application.core.FocusManager.getInstance().reset();
  64.          if(this.lastContent != activeSub)
  65.          {
  66.             this.lastContent = activeSub;
  67.             this.configPath = this.dataObj.help.contentList[activeSub].site;
  68.             if(this.configPath.indexOf(".swf",0) == -1)
  69.             {
  70.                var _loc14_ = new XML();
  71.                _loc14_.ignoreWhite = true;
  72.                var xmlHolder = this;
  73.                _loc14_.onLoad = function(succsess)
  74.                {
  75.                   if(succsess)
  76.                   {
  77.                      xmlHolder.onLoadXMLHelp(this);
  78.                   }
  79.                };
  80.                _loc14_.load(this.configPath);
  81.             }
  82.             else
  83.             {
  84.                this.loadSWF(this.configPath);
  85.             }
  86.          }
  87.          else
  88.          {
  89.             this.build();
  90.          }
  91.       }
  92.       else
  93.       {
  94.          var _loc8_ = 123;
  95.          var _loc4_ = {h:0,w:0};
  96.          var _loc3_ = 0;
  97.          while(_loc3_ < this.topics[subContent].answer.length)
  98.          {
  99.             this.container = this.contentHolder.createEmptyMovieClip("cont" + this.instCounter,this.instCounter++);
  100.             this.container._x = 43;
  101.             this.container._y = _loc8_;
  102.             if(this.topics[subContent].answer[_loc3_].indexOf("<img") == -1)
  103.             {
  104.                var _loc6_ = new application.ui.DynamicHelpTextfield();
  105.                _loc6_.setContainer(this.container);
  106.                _loc6_.setTopic(this.topics);
  107.                var _loc5_ = _loc6_.run(subContent,_loc3_);
  108.                this.lastTopic = _loc5_.mc;
  109.                _loc5_.h += 12;
  110.                _loc4_.h += int(_loc5_.h);
  111.                _loc8_ += int(_loc5_.h);
  112.                if(_loc5_.w > _loc4_.w)
  113.                {
  114.                   _loc4_.w = _loc5_.w;
  115.                }
  116.             }
  117.             else
  118.             {
  119.                var _loc10_ = this.topics[subContent].answer[_loc3_];
  120.                var _loc2_ = _loc10_.indexOf("src=") + 5;
  121.                var _loc11_ = _loc10_.indexOf("\"",_loc2_);
  122.                var _loc9_ = _loc10_.substring(_loc2_,_loc11_);
  123.                _loc2_ = _loc10_.indexOf("width=") + 7;
  124.                _loc11_ = _loc10_.indexOf("\"",_loc2_);
  125.                var _loc13_ = Number(_loc10_.substring(_loc2_,_loc11_));
  126.                _loc2_ = _loc10_.indexOf("height=") + 8;
  127.                _loc11_ = _loc10_.indexOf("\"",_loc2_);
  128.                var _loc12_ = Number(_loc10_.substring(_loc2_,_loc11_));
  129.                _loc10_ = this.configObj.FILEPREFIX + this.configObj.HELP + _loc9_;
  130.                this.container.loadMovie(_loc10_);
  131.                _loc5_ = {h:_loc12_ + 12,w:_loc13_};
  132.                _loc4_.h += _loc5_.h;
  133.                _loc8_ += _loc5_.h;
  134.                if(_loc5_.w > _loc4_.w)
  135.                {
  136.                   _loc4_.w = _loc5_.w;
  137.                }
  138.             }
  139.             _loc3_ = _loc3_ + 1;
  140.          }
  141.          this.background.beginFill(16777215,100);
  142.          this.background.moveTo(22,107);
  143.          this.background.lineTo(22,123 + _loc4_.h + 4);
  144.          this.background.lineTo(560,123 + _loc4_.h + 4);
  145.          this.background.lineTo(560,107);
  146.          this.background.lineTo(22,107);
  147.          this.background.endFill();
  148.          this.rootMC.updateView(this.background._height,true,subContent);
  149.          _loc4_ = {};
  150.       }
  151.    }
  152.    function getTopicLength()
  153.    {
  154.       return this.topics.length;
  155.    }
  156.    function showNextContent(subContent)
  157.    {
  158.       this.update(this.lastContent,subContent);
  159.    }
  160.    function build()
  161.    {
  162.       var _loc3_ = 0;
  163.       while(_loc3_ < this.topics.length)
  164.       {
  165.          var _loc6_ = this.contentHolder.createEmptyMovieClip("topic" + _loc3_,this.instCounter++);
  166.          var _loc4_ = this.format.getTextExtent(_loc3_ + 1 + ". " + this.topics[_loc3_].question,465);
  167.          _loc6_.createTextField("tf",2,23,0,_loc4_.textFieldWidth,_loc4_.textFieldHeight);
  168.          var _loc5_ = _loc6_.tf;
  169.          _loc5_.autoSize = false;
  170.          _loc5_.embedFonts = true;
  171.          _loc5_.multiline = true;
  172.          _loc5_.wordWrap = true;
  173.          _loc5_.selectable = false;
  174.          _loc5_.border = false;
  175.          _loc5_.html = true;
  176.          _loc5_.htmlText = this.topics[_loc3_].question;
  177.          _loc5_.setTextFormat(this.format);
  178.          _loc6_.createTextField("tf1",3,0,0,25,_loc4_.textFieldHeight);
  179.          _loc5_ = _loc6_.tf1;
  180.          _loc5_.autoSize = false;
  181.          _loc5_.embedFonts = true;
  182.          _loc5_.multiline = true;
  183.          _loc5_.wordWrap = true;
  184.          _loc5_.selectable = false;
  185.          _loc5_.border = false;
  186.          _loc5_.html = true;
  187.          if(_loc3_ + 1 >= 10)
  188.          {
  189.             _loc5_.htmlText = _loc3_ + 1 + ". ";
  190.          }
  191.          else
  192.          {
  193.             _loc5_.htmlText = "0" + (_loc3_ + 1) + ". ";
  194.          }
  195.          _loc5_.setTextFormat(this.format);
  196.          _loc5_ = _loc6_.tf;
  197.          var _loc2_ = _loc6_.createEmptyMovieClip("background",1);
  198.          _loc2_.clear();
  199.          _loc2_.beginFill(16777215,0);
  200.          _loc2_.moveTo(0,0);
  201.          _loc2_.lineTo(0,_loc4_.textFieldHeight);
  202.          _loc2_.lineTo(_loc4_.textFieldWidth + 20,_loc4_.textFieldHeight);
  203.          _loc2_.lineTo(_loc4_.textFieldWidth + 20,0);
  204.          _loc2_.lineTo(0,0);
  205.          _loc2_.endFill();
  206.          this.buildButton(_loc2_);
  207.          _loc6_.btnID = _loc3_;
  208.          this.createFocusRec(_loc2_,_loc2_._width,_loc6_._height,0,0);
  209.          application.core.FocusManager.getInstance().registerButton(_loc2_,40 + _loc3_);
  210.          if(this.lastTopic != null)
  211.          {
  212.             _loc6_._y = this.lastTopic._y + this.lastTopic._height + 5;
  213.             _loc6_._x = this.lastTopic._x;
  214.          }
  215.          else
  216.          {
  217.             _loc6_._y = 123;
  218.             _loc6_._x = 43;
  219.          }
  220.          this.lastTopic = _loc6_;
  221.          _loc3_ = _loc3_ + 1;
  222.       }
  223.       _loc6_ = this.background;
  224.       _loc6_.clear();
  225.       _loc6_.moveTo(22,107);
  226.       _loc6_.beginFill(16777215,100);
  227.       _loc6_.lineTo(22,this.lastTopic._y + this.lastTopic._height + 16);
  228.       _loc6_.lineTo(560,this.lastTopic._y + this.lastTopic._height + 16);
  229.       _loc6_.lineTo(560,107);
  230.       _loc6_.lineTo(22,107);
  231.       _loc6_.endFill();
  232.       this.rootMC.updateView(this.background._height,false,null);
  233.    }
  234.    function onButtonRollOver(mc)
  235.    {
  236.       var _loc2_ = mc._parent.tf;
  237.       _loc2_.setTextFormat(this.format1);
  238.       _loc2_ = mc._parent.tf1;
  239.       _loc2_.setTextFormat(this.format1);
  240.    }
  241.    function onButtonRollOut(mc)
  242.    {
  243.       var _loc2_ = mc._parent.tf;
  244.       _loc2_.setTextFormat(this.format);
  245.       _loc2_ = mc._parent.tf1;
  246.       _loc2_.setTextFormat(this.format);
  247.    }
  248.    function onButtonPress(mc)
  249.    {
  250.    }
  251.    function onButtonRelease(mc)
  252.    {
  253.       var _loc4_ = mc._parent.btnID;
  254.       var _loc2_ = 0;
  255.       while(_loc2_ < this.topics.length)
  256.       {
  257.          var _loc3_ = this.contentHolder["topic" + _loc2_].background;
  258.          application.core.FocusManager.getInstance().unregister(_loc3_.tabId,_loc3_);
  259.          _loc2_ = _loc2_ + 1;
  260.       }
  261.       this.rootMC.showInfo(_loc4_);
  262.    }
  263.    function onButtonDisable(mc)
  264.    {
  265.    }
  266.    function onButtonEnable(mc)
  267.    {
  268.    }
  269.    function parseXML(success)
  270.    {
  271.       var _loc4_ = this.contentXML.firstChild;
  272.       this.topics = [];
  273.       var _loc2_ = 0;
  274.       while(_loc2_ < _loc4_.childNodes.length)
  275.       {
  276.          this.topics[_loc2_] = {question:_loc4_.childNodes[_loc2_].childNodes[0].firstChild.nodeValue};
  277.          this.topics[_loc2_].answer = [];
  278.          var _loc3_ = 0;
  279.          while(_loc3_ < _loc4_.childNodes[_loc2_].childNodes[1].childNodes.length)
  280.          {
  281.             this.topics[_loc2_].answer[_loc3_] = _loc4_.childNodes[_loc2_].childNodes[1].childNodes[_loc3_].firstChild.nodeValue;
  282.             _loc3_ = _loc3_ + 1;
  283.          }
  284.          _loc2_ = _loc2_ + 1;
  285.       }
  286.       this.build();
  287.    }
  288.    function onButtonReleaseOutside(mc)
  289.    {
  290.    }
  291.    function loadSWF(url)
  292.    {
  293.       this.contentHolder.loadMovie(url);
  294.       this.onEnterFrame = function()
  295.       {
  296.          if(this.contentHolder.getBytesLoaded() >= this.contentHolder.getBytesTotal() && this.contentHolder.getBytesTotal() >= 10)
  297.          {
  298.             delete this.onEnterFrame;
  299.             this.rootMC.updateView(this.contentHolder._height,false,null);
  300.          }
  301.       };
  302.    }
  303. }
  304.