home *** CD-ROM | disk | FTP | other *** search
/ Hentai Interactivo 42 / HENTAI_42.bin / flip1.swf / scripts / __Packages / mx / controls / SimpleButton.as < prev    next >
Text File  |  2008-03-27  |  14KB  |  546 lines

  1. class mx.controls.SimpleButton extends mx.core.UIComponent
  2. {
  3.    static var symbolName = "SimpleButton";
  4.    static var symbolOwner = mx.controls.SimpleButton;
  5.    static var version = "2.0.2.127";
  6.    var className = "SimpleButton";
  7.    var style3dInset = 4;
  8.    var btnOffset = 1;
  9.    var __toggle = false;
  10.    var __state = false;
  11.    var __emphasized = false;
  12.    var __emphatic = false;
  13.    static var falseUp = 0;
  14.    static var falseDown = 1;
  15.    static var falseOver = 2;
  16.    static var falseDisabled = 3;
  17.    static var trueUp = 4;
  18.    static var trueDown = 5;
  19.    static var trueOver = 6;
  20.    static var trueDisabled = 7;
  21.    var falseUpSkin = "SimpleButtonUp";
  22.    var falseDownSkin = "SimpleButtonIn";
  23.    var falseOverSkin = "";
  24.    var falseDisabledSkin = "SimpleButtonUp";
  25.    var trueUpSkin = "SimpleButtonIn";
  26.    var trueDownSkin = "";
  27.    var trueOverSkin = "";
  28.    var trueDisabledSkin = "SimpleButtonIn";
  29.    var falseUpIcon = "";
  30.    var falseDownIcon = "";
  31.    var falseOverIcon = "";
  32.    var falseDisabledIcon = "";
  33.    var trueUpIcon = "";
  34.    var trueDownIcon = "";
  35.    var trueOverIcon = "";
  36.    var trueDisabledIcon = "";
  37.    var phase = "up";
  38.    var fui = "falseUpIcon";
  39.    var fus = "falseUpSkin";
  40.    var fdi = "falseDownIcon";
  41.    var fds = "falseDownSkin";
  42.    var frs = "falseOverSkin";
  43.    var fri = "falseOverIcon";
  44.    var dfi = "falseDisabledIcon";
  45.    var dfs = "falseDisabledSkin";
  46.    var tui = "trueUpIcon";
  47.    var tus = "trueUpSkin";
  48.    var tdi = "trueDownIcon";
  49.    var tds = "trueDownSkin";
  50.    var trs = "trueOverSkin";
  51.    var tri = "trueOverIcon";
  52.    var dts = "trueDisabledSkin";
  53.    var dti = "trueDisabledIcon";
  54.    var rolloverSkin = mx.controls.SimpleButton.prototype.frs;
  55.    var rolloverIcon = mx.controls.SimpleButton.prototype.fri;
  56.    var upSkin = mx.controls.SimpleButton.prototype.fus;
  57.    var downSkin = mx.controls.SimpleButton.prototype.fds;
  58.    var disabledSkin = mx.controls.SimpleButton.prototype.dfs;
  59.    var upIcon = mx.controls.SimpleButton.prototype.fui;
  60.    var downIcon = mx.controls.SimpleButton.prototype.fdi;
  61.    var disabledIcon = mx.controls.SimpleButton.prototype.dfi;
  62.    var initializing = true;
  63.    var idNames = ["fus","fds","frs","dfs","tus","tds","trs","dts","fui","fdi","fri","dfi","tui","tdi","tri","dti"];
  64.    var stateNames = ["falseUp","falseDown","falseOver","falseDisabled","trueUp","trueDown","trueOver","trueDisabled"];
  65.    var refNames = ["upSkin","downSkin","rolloverSkin","disabledSkin"];
  66.    var tagMap = {falseUpSkin:0,falseDownSkin:1,falseOverSkin:2,falseDisabledSkin:3,trueUpSkin:4,trueDownSkin:5,trueOverSkin:6,trueDisabledSkin:7,falseUpIcon:0,falseDownIcon:1,falseOverIcon:2,falseDisabledIcon:3,trueUpIcon:4,trueDownIcon:5,trueOverIcon:6,trueDisabledIcon:7};
  67.    function SimpleButton()
  68.    {
  69.       super();
  70.    }
  71.    function init(Void)
  72.    {
  73.       super.init();
  74.       if(this.preset == undefined)
  75.       {
  76.          this.boundingBox_mc._visible = false;
  77.          this.boundingBox_mc._width = this.boundingBox_mc._height = 0;
  78.       }
  79.       this.useHandCursor = false;
  80.    }
  81.    function createChildren(Void)
  82.    {
  83.       if(this.preset != undefined)
  84.       {
  85.          var _loc2_ = this[this.idNames[this.preset]];
  86.          this[this.refNames[this.preset]] = _loc2_;
  87.          this.skinName = _loc2_;
  88.          if(this.falseOverSkin.length == 0)
  89.          {
  90.             this.rolloverSkin = this.fus;
  91.          }
  92.          if(this.falseOverIcon.length == 0)
  93.          {
  94.             this.rolloverIcon = this.fui;
  95.          }
  96.          this.initializing = false;
  97.       }
  98.       else if(this.__state == true)
  99.       {
  100.          this.setStateVar(true);
  101.       }
  102.       else
  103.       {
  104.          if(this.falseOverSkin.length == 0)
  105.          {
  106.             this.rolloverSkin = this.fus;
  107.          }
  108.          if(this.falseOverIcon.length == 0)
  109.          {
  110.             this.rolloverIcon = this.fui;
  111.          }
  112.       }
  113.    }
  114.    function setIcon(tag, linkageName)
  115.    {
  116.       return this.setSkin(tag + 8,linkageName);
  117.    }
  118.    function changeIcon(tag, linkageName)
  119.    {
  120.       this.linkLength = linkageName.length;
  121.       var _loc2_ = this.stateNames[tag] + "Icon";
  122.       this[_loc2_] = linkageName;
  123.       this[this.idNames[tag + 8]] = _loc2_;
  124.       this.setStateVar(this.getState());
  125.    }
  126.    function changeSkin(tag, linkageName)
  127.    {
  128.       var _loc2_ = this.stateNames[tag] + "Skin";
  129.       this[_loc2_] = linkageName;
  130.       this[this.idNames[tag]] = _loc2_;
  131.       this.setStateVar(this.getState());
  132.    }
  133.    function viewIcon(varName)
  134.    {
  135.       var _loc4_ = varName + "Icon";
  136.       var _loc3_ = this[_loc4_];
  137.       if(typeof _loc3_ == "string")
  138.       {
  139.          var _loc5_ = _loc3_;
  140.          if(this.__emphasized)
  141.          {
  142.             if(this[_loc3_ + "Emphasized"].length > 0)
  143.             {
  144.                _loc3_ += "Emphasized";
  145.             }
  146.          }
  147.          if(this[_loc3_].length == 0)
  148.          {
  149.             return undefined;
  150.          }
  151.          _loc3_ = this.setIcon(this.tagMap[_loc5_],this[_loc3_]);
  152.          if(_loc3_ == undefined && _global.isLivePreview)
  153.          {
  154.             _loc3_ = this.setIcon(0,"ButtonIcon");
  155.          }
  156.          this[_loc4_] = _loc3_;
  157.       }
  158.       this.iconName._visible = false;
  159.       this.iconName = _loc3_;
  160.       this.iconName._visible = true;
  161.    }
  162.    function removeIcons()
  163.    {
  164.       var _loc3_ = 0;
  165.       while(_loc3_ < 2)
  166.       {
  167.          var _loc2_ = 8;
  168.          while(_loc2_ < 16)
  169.          {
  170.             this.destroyObject(this.idNames[_loc2_]);
  171.             this[this.stateNames[_loc2_ - 8] + "Icon"] = "";
  172.             _loc2_ = _loc2_ + 1;
  173.          }
  174.          _loc3_ = _loc3_ + 1;
  175.       }
  176.       this.refresh();
  177.    }
  178.    function setSkin(tag, linkageName, initobj)
  179.    {
  180.       var _loc3_ = super.setSkin(tag,linkageName,initobj == undefined ? {styleName:this} : initobj);
  181.       this.calcSize(tag,_loc3_);
  182.       return _loc3_;
  183.    }
  184.    function calcSize(Void)
  185.    {
  186.       this.__width = this._width;
  187.       this.__height = this._height;
  188.    }
  189.    function viewSkin(varName, initObj)
  190.    {
  191.       var _loc3_ = varName + "Skin";
  192.       var _loc2_ = this[_loc3_];
  193.       if(typeof _loc2_ == "string")
  194.       {
  195.          var _loc4_ = _loc2_;
  196.          if(this.__emphasized)
  197.          {
  198.             if(this[_loc2_ + "Emphasized"].length > 0)
  199.             {
  200.                _loc2_ += "Emphasized";
  201.             }
  202.          }
  203.          if(this[_loc2_].length == 0)
  204.          {
  205.             return undefined;
  206.          }
  207.          _loc2_ = this.setSkin(this.tagMap[_loc4_],this[_loc2_],initObj == undefined ? {styleName:this} : initObj);
  208.          this[_loc3_] = _loc2_;
  209.       }
  210.       this.skinName._visible = false;
  211.       this.skinName = _loc2_;
  212.       this.skinName._visible = true;
  213.    }
  214.    function showEmphasized(e)
  215.    {
  216.       if(e && !this.__emphatic)
  217.       {
  218.          if(mx.controls.SimpleButton.emphasizedStyleDeclaration != undefined)
  219.          {
  220.             this.__emphaticStyleName = this.styleName;
  221.             this.styleName = mx.controls.SimpleButton.emphasizedStyleDeclaration;
  222.          }
  223.          this.__emphatic = true;
  224.       }
  225.       else
  226.       {
  227.          if(this.__emphatic)
  228.          {
  229.             this.styleName = this.__emphaticStyleName;
  230.          }
  231.          this.__emphatic = false;
  232.       }
  233.    }
  234.    function refresh(Void)
  235.    {
  236.       var _loc2_ = this.getState();
  237.       if(this.enabled == false)
  238.       {
  239.          this.viewIcon("disabled");
  240.          this.viewSkin("disabled");
  241.       }
  242.       else
  243.       {
  244.          this.viewSkin(this.phase);
  245.          this.viewIcon(this.phase);
  246.       }
  247.       this.setView(this.phase == "down");
  248.       this.iconName.enabled = this.enabled;
  249.    }
  250.    function setView(offset)
  251.    {
  252.       if(this.iconName == undefined)
  253.       {
  254.          return undefined;
  255.       }
  256.       var _loc2_ = !offset ? 0 : this.btnOffset;
  257.       this.iconName._x = (this.__width - this.iconName._width) / 2 + _loc2_;
  258.       this.iconName._y = (this.__height - this.iconName._height) / 2 + _loc2_;
  259.    }
  260.    function setStateVar(state)
  261.    {
  262.       if(state)
  263.       {
  264.          if(this.trueOverSkin.length == 0)
  265.          {
  266.             this.rolloverSkin = this.tus;
  267.          }
  268.          else
  269.          {
  270.             this.rolloverSkin = this.trs;
  271.          }
  272.          if(this.trueOverIcon.length == 0)
  273.          {
  274.             this.rolloverIcon = this.tui;
  275.          }
  276.          else
  277.          {
  278.             this.rolloverIcon = this.tri;
  279.          }
  280.          this.upSkin = this.tus;
  281.          this.downSkin = this.tds;
  282.          this.disabledSkin = this.dts;
  283.          this.upIcon = this.tui;
  284.          this.downIcon = this.tdi;
  285.          this.disabledIcon = this.dti;
  286.       }
  287.       else
  288.       {
  289.          if(this.falseOverSkin.length == 0)
  290.          {
  291.             this.rolloverSkin = this.fus;
  292.          }
  293.          else
  294.          {
  295.             this.rolloverSkin = this.frs;
  296.          }
  297.          if(this.falseOverIcon.length == 0)
  298.          {
  299.             this.rolloverIcon = this.fui;
  300.          }
  301.          else
  302.          {
  303.             this.rolloverIcon = this.fri;
  304.          }
  305.          this.upSkin = this.fus;
  306.          this.downSkin = this.fds;
  307.          this.disabledSkin = this.dfs;
  308.          this.upIcon = this.fui;
  309.          this.downIcon = this.fdi;
  310.          this.disabledIcon = this.dfi;
  311.       }
  312.       this.__state = state;
  313.    }
  314.    function setState(state)
  315.    {
  316.       if(state != this.__state)
  317.       {
  318.          this.setStateVar(state);
  319.          this.invalidate();
  320.       }
  321.    }
  322.    function size(Void)
  323.    {
  324.       this.refresh();
  325.    }
  326.    function draw(Void)
  327.    {
  328.       if(this.initializing)
  329.       {
  330.          this.initializing = false;
  331.          this.skinName.visible = true;
  332.          this.iconName.visible = true;
  333.       }
  334.       this.size();
  335.    }
  336.    function getState(Void)
  337.    {
  338.       return this.__state;
  339.    }
  340.    function setToggle(val)
  341.    {
  342.       this.__toggle = val;
  343.       if(this.__toggle == false)
  344.       {
  345.          this.setState(false);
  346.       }
  347.    }
  348.    function getToggle(Void)
  349.    {
  350.       return this.__toggle;
  351.    }
  352.    function set toggle(val)
  353.    {
  354.       this.setToggle(val);
  355.    }
  356.    function get toggle()
  357.    {
  358.       return this.getToggle();
  359.    }
  360.    function set value(val)
  361.    {
  362.       this.setSelected(val);
  363.    }
  364.    function get value()
  365.    {
  366.       return this.getSelected();
  367.    }
  368.    function set selected(val)
  369.    {
  370.       this.setSelected(val);
  371.    }
  372.    function get selected()
  373.    {
  374.       return this.getSelected();
  375.    }
  376.    function setSelected(val)
  377.    {
  378.       if(this.__toggle)
  379.       {
  380.          this.setState(val);
  381.       }
  382.       else
  383.       {
  384.          this.setState(!this.initializing ? this.__state : val);
  385.       }
  386.    }
  387.    function getSelected()
  388.    {
  389.       return this.__state;
  390.    }
  391.    function setEnabled(val)
  392.    {
  393.       if(this.enabled != val)
  394.       {
  395.          super.setEnabled(val);
  396.          this.invalidate();
  397.       }
  398.    }
  399.    function onPress(Void)
  400.    {
  401.       this.pressFocus();
  402.       this.phase = "down";
  403.       this.refresh();
  404.       this.dispatchEvent({type:"buttonDown"});
  405.       if(this.autoRepeat)
  406.       {
  407.          this.interval = setInterval(this,"onPressDelay",this.getStyle("repeatDelay"));
  408.       }
  409.    }
  410.    function onPressDelay(Void)
  411.    {
  412.       this.dispatchEvent({type:"buttonDown"});
  413.       if(this.autoRepeat)
  414.       {
  415.          clearInterval(this.interval);
  416.          this.interval = setInterval(this,"onPressRepeat",this.getStyle("repeatInterval"));
  417.       }
  418.    }
  419.    function onPressRepeat(Void)
  420.    {
  421.       this.dispatchEvent({type:"buttonDown"});
  422.       updateAfterEvent();
  423.    }
  424.    function onRelease(Void)
  425.    {
  426.       this.releaseFocus();
  427.       this.phase = "rollover";
  428.       if(this.interval != undefined)
  429.       {
  430.          clearInterval(this.interval);
  431.          delete this.interval;
  432.       }
  433.       if(this.getToggle())
  434.       {
  435.          this.setState(!this.getState());
  436.       }
  437.       else
  438.       {
  439.          this.refresh();
  440.       }
  441.       this.dispatchEvent({type:"click"});
  442.    }
  443.    function onDragOut(Void)
  444.    {
  445.       this.phase = "up";
  446.       this.refresh();
  447.       this.dispatchEvent({type:"buttonDragOut"});
  448.    }
  449.    function onDragOver(Void)
  450.    {
  451.       if(this.phase != "up")
  452.       {
  453.          this.onPress();
  454.          return undefined;
  455.       }
  456.       this.phase = "down";
  457.       this.refresh();
  458.    }
  459.    function onReleaseOutside(Void)
  460.    {
  461.       this.releaseFocus();
  462.       this.phase = "up";
  463.       if(this.interval != undefined)
  464.       {
  465.          clearInterval(this.interval);
  466.          delete this.interval;
  467.       }
  468.    }
  469.    function onRollOver(Void)
  470.    {
  471.       this.phase = "rollover";
  472.       this.refresh();
  473.    }
  474.    function onRollOut(Void)
  475.    {
  476.       this.phase = "up";
  477.       this.refresh();
  478.    }
  479.    function getLabel(Void)
  480.    {
  481.       return this.fui.text;
  482.    }
  483.    function setLabel(val)
  484.    {
  485.       if(typeof this.fui == "string")
  486.       {
  487.          this.createLabel("fui",8,val);
  488.          this.fui.styleName = this;
  489.       }
  490.       else
  491.       {
  492.          this.fui.text = val;
  493.       }
  494.       var _loc4_ = this.fui._getTextFormat();
  495.       var _loc2_ = _loc4_.getTextExtent2(val);
  496.       this.fui._width = _loc2_.width + 5;
  497.       this.fui._height = _loc2_.height + 5;
  498.       this.iconName = this.fui;
  499.       this.setView(this.__state);
  500.    }
  501.    function get emphasized()
  502.    {
  503.       return this.__emphasized;
  504.    }
  505.    function set emphasized(val)
  506.    {
  507.       this.__emphasized = val;
  508.       var _loc2_ = 0;
  509.       while(_loc2_ < 8)
  510.       {
  511.          this[this.idNames[_loc2_]] = this.stateNames[_loc2_] + "Skin";
  512.          if(typeof this[this.idNames[_loc2_ + 8]] == "movieclip")
  513.          {
  514.             this[this.idNames[_loc2_ + 8]] = this.stateNames[_loc2_] + "Icon";
  515.          }
  516.          _loc2_ = _loc2_ + 1;
  517.       }
  518.       this.showEmphasized(this.__emphasized);
  519.       this.setStateVar(this.__state);
  520.       this.invalidateStyle();
  521.    }
  522.    function keyDown(e)
  523.    {
  524.       if(e.code == 32)
  525.       {
  526.          this.onPress();
  527.       }
  528.    }
  529.    function keyUp(e)
  530.    {
  531.       if(e.code == 32)
  532.       {
  533.          this.onRelease();
  534.       }
  535.    }
  536.    function onKillFocus(newFocus)
  537.    {
  538.       super.onKillFocus();
  539.       if(this.phase != "up")
  540.       {
  541.          this.phase = "up";
  542.          this.refresh();
  543.       }
  544.    }
  545. }
  546.