home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / com / facebook / views / Distractor.as < prev    next >
Encoding:
Text File  |  2010-06-23  |  3.4 KB  |  115 lines

  1. package com.facebook.views
  2. {
  3.    import flash.display.Sprite;
  4.    import flash.events.Event;
  5.    import flash.text.TextField;
  6.    import flash.text.TextFormat;
  7.    
  8.    public class Distractor extends Sprite
  9.    {
  10.       protected var dots:Sprite;
  11.       
  12.       protected var _text:String;
  13.       
  14.       public var fadeDuration:Number = 800;
  15.       
  16.       protected var tf:TextField;
  17.       
  18.       protected var totalElapsed:Number = 0;
  19.       
  20.       protected var dotWidth:Number = 40;
  21.       
  22.       protected var dotHeight:Number = 20;
  23.       
  24.       public function Distractor()
  25.       {
  26.          super();
  27.          this.configUI();
  28.       }
  29.       
  30.       public function set text(param1:String) : void
  31.       {
  32.          this.tf.text = param1;
  33.          this.tf.width = this.tf.textWidth + 10;
  34.          this.dots.x = this.tf.width;
  35.       }
  36.       
  37.       override public function set visible(param1:Boolean) : void
  38.       {
  39.          if(super.visible == param1)
  40.          {
  41.             return;
  42.          }
  43.          super.visible = param1;
  44.          if(visible)
  45.          {
  46.             addEventListener(Event.ENTER_FRAME,this.onTick,false,0,true);
  47.          }
  48.          else
  49.          {
  50.             removeEventListener(Event.ENTER_FRAME,this.onTick);
  51.          }
  52.       }
  53.       
  54.       public function get text() : String
  55.       {
  56.          return this.tf.text;
  57.       }
  58.       
  59.       protected function invCos(param1:Number) : Number
  60.       {
  61.          return 1 - 0.5 * (Math.cos(param1 * Math.PI) + 1);
  62.       }
  63.       
  64.       protected function configUI() : void
  65.       {
  66.          var _loc1_:TextFormat = new TextFormat("_sans",11);
  67.          this.tf = new TextField();
  68.          this.tf.selectable = false;
  69.          this.tf.defaultTextFormat = _loc1_;
  70.          addChild(this.tf);
  71.          this.dots = new Sprite();
  72.          addChild(this.dots);
  73.          this.dots.x = this.tf.width;
  74.          addEventListener(Event.ENTER_FRAME,this.onTick,false,0,true);
  75.       }
  76.       
  77.       protected function clamp(param1:Number, param2:Number = 0, param3:Number = 1) : Number
  78.       {
  79.          if(param1 < param2)
  80.          {
  81.             return param2;
  82.          }
  83.          if(param1 > param3)
  84.          {
  85.             return param3;
  86.          }
  87.          return param1;
  88.       }
  89.       
  90.       protected function onTick(param1:Event) : void
  91.       {
  92.          var _loc2_:Number = NaN;
  93.          this.totalElapsed += 20;
  94.          this.dots.graphics.clear();
  95.          var _loc3_:Number = Math.floor(this.dotHeight);
  96.          var _loc4_:Number = Math.floor(_loc3_ * 0.3);
  97.          var _loc5_:Number = Math.round(this.dotWidth / 3 * 0.6);
  98.          var _loc6_:Number = Math.round(this.dotWidth / 3 * 0.4);
  99.          var _loc7_:Number = _loc3_ - _loc4_;
  100.          var _loc8_:int = 0;
  101.          while(_loc8_ < 3)
  102.          {
  103.             _loc2_ = (this.totalElapsed + (3 - _loc8_) * this.fadeDuration * 0.13) % this.fadeDuration;
  104.             _loc2_ = this.invCos(1 - this.clamp(_loc2_ / (0.6 * this.fadeDuration)));
  105.             this.dots.graphics.lineStyle(1,5729956,_loc2_ * 0.7 + 0.3,true);
  106.             this.dots.graphics.beginFill(11647699,_loc2_ * 0.7 + 0.3);
  107.             this.dots.graphics.drawRoundRect(0.5 + _loc8_ * (_loc6_ + _loc5_),0.5 + 0.5 * (_loc7_ - _loc2_ * _loc7_),_loc5_,_loc4_ + _loc2_ * _loc7_,2);
  108.             this.dots.graphics.endFill();
  109.             _loc8_++;
  110.          }
  111.       }
  112.    }
  113. }
  114.  
  115.