home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 August / DPPCPRO0805.ISO / Assets / Interface / Install.dxr / 00001_Install Window.swf / scripts / __Packages / InstallStep.as
Encoding:
Text File  |  2005-05-18  |  9.0 KB  |  264 lines

  1. class InstallStep extends mx.core.UIObject
  2. {
  3.    var __stepRefs;
  4.    var __bottom;
  5.    var __btnListener;
  6.    var __scrollPane;
  7.    var __stepsClip;
  8.    var dispatchEvent;
  9.    static var symbolName = "InstallStep";
  10.    static var symbolOwner = InstallStep;
  11.    var className = "InstallStep";
  12.    static var version = "0.0.0.1";
  13.    static var __maxPageHeight = 300;
  14.    static var __pageBorder = 5;
  15.    static var __vSpacing = 5;
  16.    static var __hSpacing = 5;
  17.    var __nextDepth = 1;
  18.    function InstallStep()
  19.    {
  20.       super();
  21.       mx.events.EventDispatcher.initialize(this);
  22.    }
  23.    function init(Void)
  24.    {
  25.       super.init();
  26.       this.__stepRefs = new Array();
  27.       this.__bottom = 0;
  28.       this.__btnListener = new Object();
  29.       this.__btnListener.click = function(evtObj)
  30.       {
  31.          _level0.getURL(evtObj.target.target);
  32.       };
  33.    }
  34.    function size(Void)
  35.    {
  36.       super.size();
  37.    }
  38.    function get numSteps()
  39.    {
  40.       return this.__stepRefs.length;
  41.    }
  42.    function set clipHolder(scrollPane)
  43.    {
  44.       this.__scrollPane = scrollPane;
  45.    }
  46.    function doneSetting()
  47.    {
  48.       trace("--- DONE SETTING ---");
  49.       trace(this.__stepRefs[0]);
  50.       trace(this.__stepRefs[0].text);
  51.       trace("");
  52.       var adjustment = this.createEmptyMovieClip("bottomAdjust",this.__nextDepth);
  53.       with(adjustment)
  54.       {
  55.          beginFill("0xFFFFE5",0);
  56.          moveTo(0,0);
  57.          lineTo(0,20);
  58.          lineTo(10,20);
  59.          endFill();
  60.       }
  61.       adjustment._visible = true;
  62.       adjustment._x = 0;
  63.       adjustment._y = this.__bottom;
  64.       this.__bottom = adjustment._y + adjustment._height;
  65.       trace("__bottom: " + this.__bottom);
  66.       trace("adjustment: " + adjustment._y);
  67.       trace("adjustment: " + adjustment._height);
  68.       if(this.__scrollPane != undefined)
  69.       {
  70.          if(this.height > this.__scrollPane.height - 4)
  71.          {
  72.             this.__scrollPane.setSize(this.__scrollPane.width + 20,this.__scrollPane.height);
  73.             this.__scrollPane.move(this.__scrollPane._x - 10,this.__scrollPane._y);
  74.          }
  75.       }
  76.       trace("numSteps: " + this.numSteps);
  77.       if(this.numSteps == 1)
  78.       {
  79.          trace("THERE IS ONLY ONE STEP");
  80.          this.__stepRefs[0].text = this.__stepRefs[0].text.slice("<img src=\'step1\' hspace=\'8\' vspace=\'3\' height=\'32\' />".length);
  81.       }
  82.       if(this.height <= this.__scrollPane.height - 4)
  83.       {
  84.          _level0.stepsPane.move(-5,29);
  85.          _level0.stepsPane.setSize(_level0.stepsPane.width + 15,_level0.stepsPane.height);
  86.          trace(this.__stepRefs[0].width);
  87.          this.__stepRefs[0].setSize(this.__stepRefs[0].width + 15,this.__stepRefs[0].height);
  88.          trace(this.__stepRefs[0].width);
  89.          trace("sending " + Math.ceil(this.__bottom) + " as bottom of Flash movie to Director");
  90.          this.repositionCloseBtn(this.__bottom);
  91.          var integerBottom = Math.ceil(this.__bottom);
  92.          ┬º┬ºpush(this.getURL("lingo: resizeDialog " add integerBottom));
  93.       }
  94.    }
  95.    function repositionCloseBtn(bottom)
  96.    {
  97.       trace("reposition received: " + bottom);
  98.       _level0.closeBtn.move(_level0.closeBtn.x,bottom + 25);
  99.       _level0.footerBar._y = bottom + 15;
  100.       _level0.footerBar._visible = true;
  101.       _level0.gradients._visible = false;
  102.       this.__bottom = _level0.closeBtn.y + _level0.closeBtn.height + 11;
  103.    }
  104.    function get clipPosn()
  105.    {
  106.       return this.__stepsClip._x + ", " + this.__stepsClip._y;
  107.    }
  108.    function set title(title)
  109.    {
  110.       var _loc2_ = this.attachMovie("Label","dlgTitle",this.__nextDepth);
  111.       this.__nextDepth = this.__nextDepth + 1;
  112.       _loc2_.autoSize = "none";
  113.       _loc2_.setSize(260,22);
  114.       _loc2_.embedFonts = true;
  115.       _loc2_.setStyle("styleName","dialogTitleStyle");
  116.       _loc2_.text = title;
  117.       _loc2_.move(34,4);
  118.    }
  119.    function set step(stepData)
  120.    {
  121.       var _loc17_ = undefined;
  122.       var _loc9_ = this.__stepRefs.length + 1;
  123.       var _loc12_ = undefined;
  124.       if(_loc9_ >= 1 && _loc9_ <= 10)
  125.       {
  126.          _loc12_ = "step" + _loc9_;
  127.       }
  128.       else
  129.       {
  130.          _loc12_ = "step25";
  131.       }
  132.       var _loc13_ = "step" + _loc9_;
  133.       var _loc3_ = this.attachMovie("TextArea",_loc13_,this.__nextDepth);
  134.       this.__nextDepth = this.__nextDepth + 1;
  135.       _loc3_.wordWrap = true;
  136.       _loc3_.editable = false;
  137.       _loc3_.label.selectable = false;
  138.       _loc3_.borderStyle = "none";
  139.       _loc3_.hScrollPolicy = _loc3_.vScrollPolicy = "off";
  140.       _loc3_.html = true;
  141.       _loc3_.embedFonts = true;
  142.       _loc3_.styleSheet = _global.stepStyles;
  143.       _loc3_.setStyle("styleName","scrollTextAreaStyle");
  144.       _loc3_.text = "<img src=\'" + _loc12_ + "\' hspace=\'8\' vspace=\'3\' height=\'32\' /><stepbody>" + stepData.stepText + "</stepbody>";
  145.       _loc3_.move(0,this.__bottom + 6);
  146.       var _loc6_ = undefined;
  147.       _loc6_ = _loc3_.styleSheet._styles.stepbody.getTextExtent(this.removeHTMLTags(stepData.stepText),305);
  148.       trace("GETTEXTEXTENT2:");
  149.       trace("  " + _loc6_);
  150.       trace("  " + _loc6_.width);
  151.       trace("  " + _loc6_.height);
  152.       var _loc16_ = _level0.stepsPane.height;
  153.       var _loc10_ = _loc6_.ascent + _loc6_.descent;
  154.       trace("rowHeight: " + _loc10_);
  155.       var _loc5_ = _loc10_ + 4;
  156.       var _loc7_ = _loc6_.textFieldHeight;
  157.       var _loc8_ = 0;
  158.       while(_loc7_ > _loc5_)
  159.       {
  160.          _loc8_ = _loc8_ + 1;
  161.          _loc7_ -= _loc5_;
  162.       }
  163.       var _loc14_ = _loc8_ != 0 ? 6 + _loc10_ + _loc8_ * _loc5_ : 6 + _loc10_;
  164.       trace("AUTO TEXTFIELDHEIGHT: " + _loc6_.textFieldHeight);
  165.       trace("ADJUSTED TEXTFIELDHEIGHT: " + 1.15 * _loc6_.textFieldHeight);
  166.       trace("MANUAL TEXTFIELDHEIGHT: " + _loc14_);
  167.       _loc3_.setSize(_loc6_.textFieldWidth,1.15 * _loc6_.textFieldHeight + 4);
  168.       this.__stepRefs.push(_loc3_);
  169.       if(_loc3_.height < 45)
  170.       {
  171.          _loc3_.setSize(_loc3_.width,48.85);
  172.       }
  173.       this.__bottom = _loc3_._y + _loc3_.height + InstallStep.__vSpacing;
  174.       if(stepData.target != undefined)
  175.       {
  176.          var _loc15_ = "btn" + _loc9_;
  177.          var _loc4_ = this.attachMovie("Button",_loc15_,this.__nextDepth);
  178.          this.__nextDepth = this.__nextDepth + 1;
  179.          _loc4_.embedFonts = true;
  180.          _loc4_.styleSheet = _global.stepStyles;
  181.          _loc4_.setStyle("styleName","buttonStyle");
  182.          _loc4_.label = stepData.btnlabel.toUpperCase();
  183.          _loc4_.target = stepData.target;
  184.          _loc4_.addEventListener("click",this.__btnListener);
  185.          _loc6_ = _loc4_.styleSheet._styles.stepbtn.getTextExtent(this.removeHTMLTags(stepData.btnlabel));
  186.          _loc4_.setSize(_loc6_.textFieldWidth + 30,_loc4_.height);
  187.          _loc4_.move(_loc3_._x + _loc3_.width - _loc4_.width - 10,this.__bottom);
  188.          this.__bottom = _loc4_.top + _loc4_.height + 2 * InstallStep.__vSpacing;
  189.       }
  190.       trace("Step text height: " + _loc3_.height);
  191.       trace("");
  192.    }
  193.    function removeHTMLTags(htmlText)
  194.    {
  195.       var _loc6_ = function(txt, index)
  196.       {
  197.          return txt.indexOf("<",index);
  198.       };
  199.       var _loc8_ = function(txt, index)
  200.       {
  201.          return txt.indexOf(">",index);
  202.       };
  203.       var _loc2_ = new Array();
  204.       var _loc7_ = 0;
  205.       var _loc9_ = undefined;
  206.       var _loc10_ = undefined;
  207.       while(_loc7_ < htmlText.length)
  208.       {
  209.          _loc9_ = _loc6_(htmlText,_loc7_);
  210.          if(_loc9_ == -1)
  211.          {
  212.             break;
  213.          }
  214.          _loc10_ = _loc8_(htmlText,_loc9_);
  215.          var _loc3_ = _loc6_(htmlText,_loc10_);
  216.          while(_loc3_ == _loc10_ + 1)
  217.          {
  218.             _loc10_ = _loc8_(htmlText,_loc3_);
  219.             _loc3_ = _loc6_(htmlText,_loc10_);
  220.          }
  221.          _loc2_.push({start:_loc9_,end:_loc10_});
  222.          _loc7_ = _loc10_ + 1;
  223.       }
  224.       var _loc5_ = 0;
  225.       while(_loc5_ < _loc2_.length)
  226.       {
  227.          _loc9_ = _loc2_[_loc5_].start;
  228.          var _loc11_ = htmlText.charAt(_loc2_[_loc5_].start);
  229.          _loc10_ = _loc2_[_loc5_].end;
  230.          var _loc12_ = htmlText.charAt(_loc2_[_loc5_].end);
  231.          var _loc16_ = htmlText.substring(_loc9_ + 1,_loc10_);
  232.          _loc5_ = _loc5_ + 1;
  233.       }
  234.       if(_loc2_.length != 0)
  235.       {
  236.          var _loc18_ = "";
  237.          if(_loc2_[0].start > 0)
  238.          {
  239.             _loc18_ += htmlText.substring(0,_loc2_[0].start);
  240.          }
  241.          var _loc4_ = 0;
  242.          while(_loc4_ < _loc2_.length - 1)
  243.          {
  244.             var _loc13_ = _loc2_[_loc4_].end + 1;
  245.             var _loc15_ = _loc2_[_loc4_ + 1].start;
  246.             _loc18_ += htmlText.substring(_loc2_[_loc4_].end + 1,_loc2_[_loc4_ + 1].start);
  247.             _loc4_ = _loc4_ + 1;
  248.          }
  249.          if(_loc2_[_loc2_.length - 1].end < htmlText.length - 1)
  250.          {
  251.             _loc18_ += htmlText.substring(_loc2_[_loc2_.length - 1].end + 1);
  252.          }
  253.          return _loc18_;
  254.       }
  255.       return htmlText;
  256.    }
  257.    function sendMessage(p_msgtxt)
  258.    {
  259.       var _loc2_ = {target:this,type:"pageReady"};
  260.       _loc2_.msgtxt = p_msgtxt;
  261.       this.dispatchEvent(_loc2_);
  262.    }
  263. }
  264.