home *** CD-ROM | disk | FTP | other *** search
- package com.facebook.views
- {
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.text.TextField;
- import flash.text.TextFormat;
-
- public class Distractor extends Sprite
- {
- protected var dots:Sprite;
-
- protected var _text:String;
-
- public var fadeDuration:Number = 800;
-
- protected var tf:TextField;
-
- protected var totalElapsed:Number = 0;
-
- protected var dotWidth:Number = 40;
-
- protected var dotHeight:Number = 20;
-
- public function Distractor()
- {
- super();
- this.configUI();
- }
-
- public function set text(param1:String) : void
- {
- this.tf.text = param1;
- this.tf.width = this.tf.textWidth + 10;
- this.dots.x = this.tf.width;
- }
-
- override public function set visible(param1:Boolean) : void
- {
- if(super.visible == param1)
- {
- return;
- }
- super.visible = param1;
- if(visible)
- {
- addEventListener(Event.ENTER_FRAME,this.onTick,false,0,true);
- }
- else
- {
- removeEventListener(Event.ENTER_FRAME,this.onTick);
- }
- }
-
- public function get text() : String
- {
- return this.tf.text;
- }
-
- protected function invCos(param1:Number) : Number
- {
- return 1 - 0.5 * (Math.cos(param1 * Math.PI) + 1);
- }
-
- protected function configUI() : void
- {
- var _loc1_:TextFormat = new TextFormat("_sans",11);
- this.tf = new TextField();
- this.tf.selectable = false;
- this.tf.defaultTextFormat = _loc1_;
- addChild(this.tf);
- this.dots = new Sprite();
- addChild(this.dots);
- this.dots.x = this.tf.width;
- addEventListener(Event.ENTER_FRAME,this.onTick,false,0,true);
- }
-
- protected function clamp(param1:Number, param2:Number = 0, param3:Number = 1) : Number
- {
- if(param1 < param2)
- {
- return param2;
- }
- if(param1 > param3)
- {
- return param3;
- }
- return param1;
- }
-
- protected function onTick(param1:Event) : void
- {
- var _loc2_:Number = NaN;
- this.totalElapsed += 20;
- this.dots.graphics.clear();
- var _loc3_:Number = Math.floor(this.dotHeight);
- var _loc4_:Number = Math.floor(_loc3_ * 0.3);
- var _loc5_:Number = Math.round(this.dotWidth / 3 * 0.6);
- var _loc6_:Number = Math.round(this.dotWidth / 3 * 0.4);
- var _loc7_:Number = _loc3_ - _loc4_;
- var _loc8_:int = 0;
- while(_loc8_ < 3)
- {
- _loc2_ = (this.totalElapsed + (3 - _loc8_) * this.fadeDuration * 0.13) % this.fadeDuration;
- _loc2_ = this.invCos(1 - this.clamp(_loc2_ / (0.6 * this.fadeDuration)));
- this.dots.graphics.lineStyle(1,5729956,_loc2_ * 0.7 + 0.3,true);
- this.dots.graphics.beginFill(11647699,_loc2_ * 0.7 + 0.3);
- this.dots.graphics.drawRoundRect(0.5 + _loc8_ * (_loc6_ + _loc5_),0.5 + 0.5 * (_loc7_ - _loc2_ * _loc7_),_loc5_,_loc4_ + _loc2_ * _loc7_,2);
- this.dots.graphics.endFill();
- _loc8_++;
- }
- }
- }
- }
-
-