home *** CD-ROM | disk | FTP | other *** search
/ Computer Arts 148 / ART_148.iso / Zasoby / Szablony Flasha / flashmo_241_multi_scroller / transitions.swf / scripts / TweenerTransitionCheatSheet.as < prev   
Encoding:
Text File  |  2007-09-13  |  19.2 KB  |  639 lines

  1. package
  2. {
  3.    import caurina.transitions.*;
  4.    import fl.controls.Button;
  5.    import flash.display.MovieClip;
  6.    import flash.display.Sprite;
  7.    import flash.events.*;
  8.    import flash.geom.*;
  9.    import flash.printing.*;
  10.    import flash.text.TextField;
  11.    
  12.    public class TweenerTransitionCheatSheet extends Sprite
  13.    {
  14.       public static const MARGIN_HORIZONTAL:Number = 14;
  15.       
  16.       public static const MARGIN_VERTICAL:Number = 10;
  17.       
  18.       public static const MARGIN_LEFT:Number = 12;
  19.       
  20.       public static const MARGIN_RIGHT:Number = 12;
  21.       
  22.       public static const MARGIN_TOP:Number = 40;
  23.       
  24.       public static const MARGIN_BOTTOM:Number = 34;
  25.       
  26.       public var messageBottom:TextField;
  27.       
  28.       public var barBottom:MovieClip;
  29.       
  30.       public var barTop:MovieClip;
  31.       
  32.       private var _firstLineHidden:Boolean;
  33.       
  34.       public var bPrint:Button;
  35.       
  36.       public var bHideFirstLine:Button;
  37.       
  38.       private var _currentDrawMode:uint;
  39.       
  40.       public var descriptionMessage:DescriptionMessage;
  41.       
  42.       private var _falseScaleX:Number = 1;
  43.       
  44.       private var _falseScaleY:Number = 1;
  45.       
  46.       public var bMode1:Button;
  47.       
  48.       public var bMode0:Button;
  49.       
  50.       public var bMode2:Button;
  51.       
  52.       private var _transitionTypes:Array;
  53.       
  54.       public function TweenerTransitionCheatSheet()
  55.       {
  56.          _falseScaleX = 1;
  57.          _falseScaleY = 1;
  58.          super();
  59.          stage.scaleMode = "noScale";
  60.          stage.align = "LT";
  61.          _transitionTypes = new Array();
  62.          _transitionTypes.push({
  63.             "name":"linear",
  64.             "equation":Equations.easeNone,
  65.             "lineFeed":true,
  66.             "drawMode":0
  67.          });
  68.          _transitionTypes.push({
  69.             "name":"easeInSine",
  70.             "equation":Equations.easeInSine,
  71.             "drawMode":0
  72.          });
  73.          _transitionTypes.push({
  74.             "name":"easeOutSine",
  75.             "equation":Equations.easeOutSine,
  76.             "drawMode":0
  77.          });
  78.          _transitionTypes.push({
  79.             "name":"easeInOutSine",
  80.             "equation":Equations.easeInOutSine,
  81.             "drawMode":1
  82.          });
  83.          _transitionTypes.push({
  84.             "name":"easeOutInSine",
  85.             "equation":Equations.easeOutInSine,
  86.             "drawMode":2
  87.          });
  88.          _transitionTypes.push({
  89.             "name":"easeInQuad",
  90.             "equation":Equations.easeInQuad,
  91.             "drawMode":0
  92.          });
  93.          _transitionTypes.push({
  94.             "name":"easeOutQuad",
  95.             "equation":Equations.easeOutQuad,
  96.             "drawMode":0
  97.          });
  98.          _transitionTypes.push({
  99.             "name":"easeInOutQuad",
  100.             "equation":Equations.easeInOutQuad,
  101.             "drawMode":1
  102.          });
  103.          _transitionTypes.push({
  104.             "name":"easeOutInQuad",
  105.             "equation":Equations.easeOutInQuad,
  106.             "drawMode":2
  107.          });
  108.          _transitionTypes.push({
  109.             "name":"easeInCubic",
  110.             "equation":Equations.easeInCubic,
  111.             "drawMode":0
  112.          });
  113.          _transitionTypes.push({
  114.             "name":"easeOutCubic",
  115.             "equation":Equations.easeOutCubic,
  116.             "drawMode":0
  117.          });
  118.          _transitionTypes.push({
  119.             "name":"easeInOutCubic",
  120.             "equation":Equations.easeInOutCubic,
  121.             "drawMode":1
  122.          });
  123.          _transitionTypes.push({
  124.             "name":"easeOutInCubic",
  125.             "equation":Equations.easeOutInCubic,
  126.             "drawMode":2
  127.          });
  128.          _transitionTypes.push({
  129.             "name":"easeInQuart",
  130.             "equation":Equations.easeInQuart,
  131.             "drawMode":0
  132.          });
  133.          _transitionTypes.push({
  134.             "name":"easeOutQuart",
  135.             "equation":Equations.easeOutQuart,
  136.             "drawMode":0
  137.          });
  138.          _transitionTypes.push({
  139.             "name":"easeInOutQuart",
  140.             "equation":Equations.easeInOutQuart,
  141.             "drawMode":1
  142.          });
  143.          _transitionTypes.push({
  144.             "name":"easeOutInQuart",
  145.             "equation":Equations.easeOutInQuart,
  146.             "drawMode":2
  147.          });
  148.          _transitionTypes.push({
  149.             "name":"easeInQuint",
  150.             "equation":Equations.easeInQuint,
  151.             "drawMode":0
  152.          });
  153.          _transitionTypes.push({
  154.             "name":"easeOutQuint",
  155.             "equation":Equations.easeOutQuint,
  156.             "drawMode":0
  157.          });
  158.          _transitionTypes.push({
  159.             "name":"easeInOutQuint",
  160.             "equation":Equations.easeInOutQuint,
  161.             "drawMode":1
  162.          });
  163.          _transitionTypes.push({
  164.             "name":"easeOutInQuint",
  165.             "equation":Equations.easeOutInQuint,
  166.             "drawMode":2
  167.          });
  168.          _transitionTypes.push({
  169.             "name":"easeInExpo",
  170.             "equation":Equations.easeInExpo,
  171.             "drawMode":0
  172.          });
  173.          _transitionTypes.push({
  174.             "name":"easeOutExpo",
  175.             "equation":Equations.easeOutExpo,
  176.             "drawMode":0
  177.          });
  178.          _transitionTypes.push({
  179.             "name":"easeInOutExpo",
  180.             "equation":Equations.easeInOutExpo,
  181.             "drawMode":1
  182.          });
  183.          _transitionTypes.push({
  184.             "name":"easeOutInExpo",
  185.             "equation":Equations.easeOutInExpo,
  186.             "drawMode":2
  187.          });
  188.          _transitionTypes.push({
  189.             "name":"easeInCirc",
  190.             "equation":Equations.easeInCirc,
  191.             "drawMode":0
  192.          });
  193.          _transitionTypes.push({
  194.             "name":"easeOutCirc",
  195.             "equation":Equations.easeOutCirc,
  196.             "drawMode":0
  197.          });
  198.          _transitionTypes.push({
  199.             "name":"easeInOutCirc",
  200.             "equation":Equations.easeInOutCirc,
  201.             "drawMode":1
  202.          });
  203.          _transitionTypes.push({
  204.             "name":"easeOutInCirc",
  205.             "equation":Equations.easeOutInCirc,
  206.             "drawMode":2
  207.          });
  208.          _transitionTypes.push({
  209.             "name":"easeInElastic",
  210.             "equation":Equations.easeInElastic,
  211.             "drawMode":0
  212.          });
  213.          _transitionTypes.push({
  214.             "name":"easeOutElastic",
  215.             "equation":Equations.easeOutElastic,
  216.             "drawMode":0
  217.          });
  218.          _transitionTypes.push({
  219.             "name":"easeInOutElastic",
  220.             "equation":Equations.easeInOutElastic,
  221.             "drawMode":1
  222.          });
  223.          _transitionTypes.push({
  224.             "name":"easeOutInElastic",
  225.             "equation":Equations.easeOutInElastic,
  226.             "drawMode":2
  227.          });
  228.          _transitionTypes.push({
  229.             "name":"easeInBack",
  230.             "equation":Equations.easeInBack,
  231.             "drawMode":0
  232.          });
  233.          _transitionTypes.push({
  234.             "name":"easeOutBack",
  235.             "equation":Equations.easeOutBack,
  236.             "drawMode":0
  237.          });
  238.          _transitionTypes.push({
  239.             "name":"easeInOutBack",
  240.             "equation":Equations.easeInOutBack,
  241.             "drawMode":1
  242.          });
  243.          _transitionTypes.push({
  244.             "name":"easeOutInBack",
  245.             "equation":Equations.easeOutInBack,
  246.             "drawMode":2
  247.          });
  248.          _transitionTypes.push({
  249.             "name":"easeInBounce",
  250.             "equation":Equations.easeInBounce,
  251.             "drawMode":0
  252.          });
  253.          _transitionTypes.push({
  254.             "name":"easeOutBounce",
  255.             "equation":Equations.easeOutBounce,
  256.             "drawMode":0
  257.          });
  258.          _transitionTypes.push({
  259.             "name":"easeInOutBounce",
  260.             "equation":Equations.easeInOutBounce,
  261.             "drawMode":1
  262.          });
  263.          _transitionTypes.push({
  264.             "name":"easeOutInBounce",
  265.             "equation":Equations.easeOutInBounce,
  266.             "drawMode":2
  267.          });
  268.          setupTransitionGrid();
  269.          bMode0.addEventListener(MouseEvent.CLICK,onClickMode0);
  270.          bMode1.addEventListener(MouseEvent.CLICK,onClickMode1);
  271.          bMode2.addEventListener(MouseEvent.CLICK,onClickMode2);
  272.          bHideFirstLine.addEventListener(MouseEvent.CLICK,toggleFirstLine);
  273.          bPrint.addEventListener(MouseEvent.CLICK,printSheet);
  274.          addEventListener(Event.ENTER_FRAME,repaintModeButtons);
  275.          stage.addEventListener(Event.RESIZE,onResize);
  276.          currentDrawMode = 1;
  277.          _firstLineHidden = false;
  278.          onResize();
  279.          __setProp_bMode2_Scene1_buttons_1();
  280.          __setProp_bMode1_Scene1_buttons_1();
  281.          __setProp_bPrint_Scene1_buttons_1();
  282.          __setProp_bMode0_Scene1_buttons_1();
  283.          __setProp_bHideFirstLine_Scene1_buttons_1();
  284.       }
  285.       
  286.       public function set firstLineHidden(param1:Boolean) : void
  287.       {
  288.          _firstLineHidden = param1;
  289.          redrawAll();
  290.       }
  291.       
  292.       public function redrawAll() : void
  293.       {
  294.          barTop.width = barBottom.width = windowWidth;
  295.          barBottom.y = windowHeight - barBottom.height;
  296.          messageBottom.x = windowWidth / 2 - messageBottom.width / 2;
  297.          messageBottom.y = barBottom.y + barBottom.height / 2 - messageBottom.height / 2;
  298.          redrawButtons();
  299.          redrawGrid();
  300.       }
  301.       
  302.       public function get windowHeight() : Number
  303.       {
  304.          return stage.stageHeight * _falseScaleY;
  305.       }
  306.       
  307.       internal function __setProp_bHideFirstLine_Scene1_buttons_1() : *
  308.       {
  309.          try
  310.          {
  311.             bHideFirstLine["componentInspectorSetting"] = true;
  312.          }
  313.          catch(e:Error)
  314.          {
  315.          }
  316.          bHideFirstLine.emphasized = false;
  317.          bHideFirstLine.enabled = true;
  318.          bHideFirstLine.label = "Hide first line";
  319.          bHideFirstLine.labelPlacement = "right";
  320.          bHideFirstLine.selected = false;
  321.          bHideFirstLine.toggle = true;
  322.          bHideFirstLine.visible = true;
  323.          try
  324.          {
  325.             bHideFirstLine["componentInspectorSetting"] = false;
  326.          }
  327.          catch(e:Error)
  328.          {
  329.          }
  330.       }
  331.       
  332.       public function setupTransitionGrid() : void
  333.       {
  334.          var _loc1_:TransitionGraphic = null;
  335.          var _loc2_:uint = 0;
  336.          _loc2_ = 0;
  337.          while(_loc2_ < _transitionTypes.length)
  338.          {
  339.             _loc1_ = new TransitionGraphic(_transitionTypes[_loc2_].name,_transitionTypes[_loc2_].equation);
  340.             addChild(_loc1_);
  341.             _loc1_.showTransition(_loc2_ * 0.1);
  342.             _transitionTypes[_loc2_].container = _loc1_;
  343.             _loc2_++;
  344.          }
  345.       }
  346.       
  347.       public function repaintModeButtons(param1:Event = null) : void
  348.       {
  349.          currentDrawMode = _currentDrawMode;
  350.          removeEventListener(Event.ENTER_FRAME,repaintModeButtons);
  351.       }
  352.       
  353.       internal function __setProp_bMode0_Scene1_buttons_1() : *
  354.       {
  355.          try
  356.          {
  357.             bMode0["componentInspectorSetting"] = true;
  358.          }
  359.          catch(e:Error)
  360.          {
  361.          }
  362.          bMode0.emphasized = false;
  363.          bMode0.enabled = true;
  364.          bMode0.label = "Simple";
  365.          bMode0.labelPlacement = "right";
  366.          bMode0.selected = false;
  367.          bMode0.toggle = false;
  368.          bMode0.visible = true;
  369.          try
  370.          {
  371.             bMode0["componentInspectorSetting"] = false;
  372.          }
  373.          catch(e:Error)
  374.          {
  375.          }
  376.       }
  377.       
  378.       public function onResize(param1:Event = null) : void
  379.       {
  380.          redrawAll();
  381.       }
  382.       
  383.       public function redrawButtons() : void
  384.       {
  385.          var _loc1_:Number = NaN;
  386.          var _loc2_:Number = NaN;
  387.          bMode0.enabled = _currentDrawMode != 0;
  388.          bMode1.enabled = _currentDrawMode != 1;
  389.          bMode2.enabled = _currentDrawMode != 2;
  390.          _loc1_ = 10;
  391.          _loc2_ = windowWidth - _loc1_;
  392.          _loc2_ -= bPrint.width;
  393.          bPrint.x = _loc2_;
  394.          _loc2_ -= _loc1_;
  395.          _loc2_ -= bHideFirstLine.width;
  396.          bHideFirstLine.x = _loc2_;
  397.          _loc2_ -= _loc1_;
  398.          _loc2_ -= bMode2.width;
  399.          bMode2.x = _loc2_;
  400.          _loc2_ -= bMode1.width - 1;
  401.          bMode1.x = _loc2_;
  402.          _loc2_ -= bMode0.width - 1;
  403.          bMode0.x = _loc2_;
  404.       }
  405.       
  406.       internal function __setProp_bMode2_Scene1_buttons_1() : *
  407.       {
  408.          try
  409.          {
  410.             bMode2["componentInspectorSetting"] = true;
  411.          }
  412.          catch(e:Error)
  413.          {
  414.          }
  415.          bMode2.emphasized = false;
  416.          bMode2.enabled = true;
  417.          bMode2.label = "Complete";
  418.          bMode2.labelPlacement = "right";
  419.          bMode2.selected = false;
  420.          bMode2.toggle = false;
  421.          bMode2.visible = true;
  422.          try
  423.          {
  424.             bMode2["componentInspectorSetting"] = false;
  425.          }
  426.          catch(e:Error)
  427.          {
  428.          }
  429.       }
  430.       
  431.       public function onClickMode2(param1:Event = null) : void
  432.       {
  433.          currentDrawMode = 2;
  434.       }
  435.       
  436.       public function onClickMode1(param1:Event = null) : void
  437.       {
  438.          currentDrawMode = 1;
  439.       }
  440.       
  441.       internal function __setProp_bMode1_Scene1_buttons_1() : *
  442.       {
  443.          try
  444.          {
  445.             bMode1["componentInspectorSetting"] = true;
  446.          }
  447.          catch(e:Error)
  448.          {
  449.          }
  450.          bMode1.emphasized = false;
  451.          bMode1.enabled = true;
  452.          bMode1.label = "Medium";
  453.          bMode1.labelPlacement = "right";
  454.          bMode1.selected = false;
  455.          bMode1.toggle = false;
  456.          bMode1.visible = true;
  457.          try
  458.          {
  459.             bMode1["componentInspectorSetting"] = false;
  460.          }
  461.          catch(e:Error)
  462.          {
  463.          }
  464.       }
  465.       
  466.       public function onClickMode0(param1:Event = null) : void
  467.       {
  468.          currentDrawMode = 0;
  469.       }
  470.       
  471.       public function get currentDrawMode() : Number
  472.       {
  473.          return _currentDrawMode;
  474.       }
  475.       
  476.       public function get firstLineHidden() : Boolean
  477.       {
  478.          return _firstLineHidden;
  479.       }
  480.       
  481.       public function set currentDrawMode(param1:Number) : void
  482.       {
  483.          _currentDrawMode = param1;
  484.          redrawAll();
  485.       }
  486.       
  487.       internal function __setProp_bPrint_Scene1_buttons_1() : *
  488.       {
  489.          try
  490.          {
  491.             bPrint["componentInspectorSetting"] = true;
  492.          }
  493.          catch(e:Error)
  494.          {
  495.          }
  496.          bPrint.emphasized = false;
  497.          bPrint.enabled = true;
  498.          bPrint.label = "Print";
  499.          bPrint.labelPlacement = "right";
  500.          bPrint.selected = false;
  501.          bPrint.toggle = false;
  502.          bPrint.visible = true;
  503.          try
  504.          {
  505.             bPrint["componentInspectorSetting"] = false;
  506.          }
  507.          catch(e:Error)
  508.          {
  509.          }
  510.       }
  511.       
  512.       public function printSheet(param1:Event = null) : void
  513.       {
  514.          var _loc2_:PrintJob = null;
  515.          var _loc3_:Rectangle = null;
  516.          _loc2_ = new PrintJob();
  517.          if(_loc2_.start())
  518.          {
  519.             bMode0.visible = bMode1.visible = bMode2.visible = bHideFirstLine.visible = bPrint.visible = false;
  520.             if(_loc2_.orientation == PrintJobOrientation.PORTRAIT)
  521.             {
  522.                rotation = 90;
  523.                _falseScaleX = _loc2_.paperHeight / windowWidth;
  524.                _falseScaleY = _loc2_.paperWidth / windowHeight;
  525.             }
  526.             else
  527.             {
  528.                rotation = 0;
  529.                _falseScaleX = _loc2_.paperWidth / windowWidth;
  530.                _falseScaleY = _loc2_.paperHeight / windowHeight;
  531.             }
  532.             redrawAll();
  533.             _loc3_ = new Rectangle(0,0,windowWidth,windowHeight);
  534.             _loc2_.addPage(this,_loc3_);
  535.             _loc2_.send();
  536.          }
  537.          rotation = 0;
  538.          _falseScaleX = _falseScaleY = 1;
  539.          bMode0.visible = bMode1.visible = bMode2.visible = bHideFirstLine.visible = bPrint.visible = true;
  540.          redrawAll();
  541.       }
  542.       
  543.       public function get windowWidth() : Number
  544.       {
  545.          return stage.stageWidth * _falseScaleX;
  546.       }
  547.       
  548.       public function toggleFirstLine(param1:Event = null) : void
  549.       {
  550.          firstLineHidden = !firstLineHidden;
  551.       }
  552.       
  553.       public function redrawGrid() : void
  554.       {
  555.          var _loc1_:uint = 0;
  556.          var _loc2_:Number = NaN;
  557.          var _loc3_:Number = NaN;
  558.          var _loc4_:uint = 0;
  559.          var _loc5_:uint = 0;
  560.          var _loc6_:Number = NaN;
  561.          var _loc7_:Number = NaN;
  562.          var _loc8_:Number = NaN;
  563.          var _loc9_:Number = NaN;
  564.          var _loc10_:TransitionGraphic = null;
  565.          _loc2_ = _currentDrawMode == 0 ? 4 : (_currentDrawMode == 1 ? 6 : 8);
  566.          _loc3_ = 0;
  567.          _loc4_ = 0;
  568.          _loc5_ = 0;
  569.          _loc1_ = 0;
  570.          while(_loc1_ < _transitionTypes.length)
  571.          {
  572.             if(_transitionTypes[_loc1_].drawMode <= _currentDrawMode)
  573.             {
  574.                if(_loc5_ == 0)
  575.                {
  576.                   _loc3_++;
  577.                }
  578.                if(++_loc5_ >= _loc2_ || Boolean(_transitionTypes[_loc1_].lineFeed))
  579.                {
  580.                   _loc5_ = 0;
  581.                }
  582.             }
  583.             _loc1_++;
  584.          }
  585.          if(_firstLineHidden)
  586.          {
  587.             _loc3_--;
  588.          }
  589.          _loc5_ = 0;
  590.          _loc6_ = MARGIN_LEFT;
  591.          _loc7_ = MARGIN_TOP;
  592.          _loc8_ = (windowWidth - MARGIN_LEFT - MARGIN_RIGHT - _loc2_ * MARGIN_HORIZONTAL) / _loc2_;
  593.          _loc9_ = (windowHeight - MARGIN_TOP - MARGIN_BOTTOM - (_loc3_ - 1) * MARGIN_VERTICAL) / _loc3_;
  594.          _loc1_ = 0;
  595.          while(_loc1_ < _transitionTypes.length)
  596.          {
  597.             _loc10_ = _transitionTypes[_loc1_].container;
  598.             if(_transitionTypes[_loc1_].drawMode <= _currentDrawMode && !(_firstLineHidden && _transitionTypes[_loc1_].lineFeed))
  599.             {
  600.                _loc10_.visible = true;
  601.                _loc10_.setSize(_loc8_,_loc9_);
  602.                _loc10_.x = _loc6_;
  603.                _loc10_.y = _loc7_;
  604.                _loc5_++;
  605.                _loc6_ += _loc8_ + MARGIN_HORIZONTAL;
  606.                if(_loc1_ == 0)
  607.                {
  608.                   descriptionMessage.visible = true;
  609.                   descriptionMessage.x = _loc6_;
  610.                   descriptionMessage.y = _loc7_;
  611.                   descriptionMessage.setSize(windowWidth - _loc6_ - MARGIN_RIGHT,_loc9_);
  612.                }
  613.                if(_loc5_ == _loc2_ / 2)
  614.                {
  615.                   _loc6_ += MARGIN_HORIZONTAL;
  616.                }
  617.                if(_loc5_ >= _loc2_ || Boolean(_transitionTypes[_loc1_].lineFeed))
  618.                {
  619.                   _loc5_ = 0;
  620.                   _loc4_++;
  621.                   _loc6_ = MARGIN_LEFT;
  622.                   _loc7_ += _loc9_ + MARGIN_VERTICAL;
  623.                }
  624.             }
  625.             else
  626.             {
  627.                _loc10_.visible = false;
  628.                if(_loc1_ == 0)
  629.                {
  630.                   descriptionMessage.visible = false;
  631.                }
  632.             }
  633.             _loc1_++;
  634.          }
  635.       }
  636.    }
  637. }
  638.  
  639.