home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / net / xinterface / display / Reflection.as < prev   
Encoding:
Text File  |  2010-06-23  |  3.4 KB  |  101 lines

  1. package net.xinterface.display
  2. {
  3.    import flash.display.Bitmap;
  4.    import flash.display.BitmapData;
  5.    import flash.display.DisplayObject;
  6.    import flash.display.GradientType;
  7.    import flash.display.SpreadMethod;
  8.    import flash.display.Sprite;
  9.    import flash.events.TimerEvent;
  10.    import flash.geom.Matrix;
  11.    import flash.geom.Point;
  12.    import flash.utils.Timer;
  13.    
  14.    public class Reflection
  15.    {
  16.       private var reflectContainer:Sprite;
  17.       
  18.       private var timer:Timer;
  19.       
  20.       private var reflectBitmap:Bitmap;
  21.       
  22.       private var destiny:Bitmap;
  23.       
  24.       private var bounds:Point;
  25.       
  26.       private var source:DisplayObject;
  27.       
  28.       public function Reflection(param1:DisplayObject, param2:Bitmap = null, param3:Number = 0.5, param4:Number = 150, param5:Number = 0)
  29.       {
  30.          var _loc12_:Number = NaN;
  31.          super();
  32.          this.source = param1;
  33.          this.bounds = new Point(this.source.width,this.source.height);
  34.          this.destiny = param2;
  35.          this.reflectBitmap = new Bitmap();
  36.          this.reflectBitmap.bitmapData = new BitmapData(this.bounds.x,this.bounds.y,true,0);
  37.          this.reflectBitmap.bitmapData.draw(this.source);
  38.          this.reflectBitmap.cacheAsBitmap = true;
  39.          this.reflectBitmap.scaleY = -1;
  40.          this.reflectBitmap.y = this.reflectBitmap.height;
  41.          var _loc6_:String = GradientType.LINEAR;
  42.          var _loc7_:Array = [16777215,16777215];
  43.          var _loc8_:Array = [param3,0];
  44.          var _loc9_:Array = [0,param4];
  45.          var _loc10_:String = SpreadMethod.REFLECT;
  46.          var _loc11_:Matrix = new Matrix();
  47.          if(param5 <= 0)
  48.          {
  49.             _loc12_ = this.bounds.y;
  50.          }
  51.          else
  52.          {
  53.             _loc12_ = this.bounds.y / param5;
  54.          }
  55.          _loc11_.createGradientBox(this.bounds.x,_loc12_,90 / 180 * Math.PI,0,0);
  56.          var _loc13_:Sprite = new Sprite();
  57.          _loc13_.graphics.beginGradientFill(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_,_loc10_);
  58.          _loc13_.graphics.drawRect(0,0,this.bounds.x,this.bounds.y);
  59.          _loc13_.graphics.endFill();
  60.          _loc13_.cacheAsBitmap = true;
  61.          this.reflectBitmap.mask = _loc13_;
  62.          this.reflectContainer = new Sprite();
  63.          this.reflectContainer.addChild(this.reflectBitmap);
  64.          this.reflectContainer.addChild(_loc13_);
  65.       }
  66.       
  67.       public function Stop() : void
  68.       {
  69.          if(this.timer != null)
  70.          {
  71.             this.timer.stop();
  72.             this.timer.removeEventListener(TimerEvent.TIMER,this.Render);
  73.             this.timer = null;
  74.          }
  75.       }
  76.       
  77.       public function Play(param1:Number = 30) : void
  78.       {
  79.          this.Stop();
  80.          this.timer = new Timer(param1);
  81.          this.timer.addEventListener(TimerEvent.TIMER,this.Render);
  82.          this.timer.start();
  83.       }
  84.       
  85.       public function Render(param1:TimerEvent = null) : BitmapData
  86.       {
  87.          this.reflectBitmap.bitmapData.dispose();
  88.          this.reflectBitmap.bitmapData = new BitmapData(this.bounds.x,this.bounds.y,true,0);
  89.          this.reflectBitmap.bitmapData.draw(this.source);
  90.          var _loc2_:BitmapData = new BitmapData(this.bounds.x,this.bounds.y,true,0);
  91.          _loc2_.draw(this.reflectContainer);
  92.          if(this.destiny)
  93.          {
  94.             this.destiny.bitmapData = _loc2_;
  95.          }
  96.          return _loc2_;
  97.       }
  98.    }
  99. }
  100.  
  101.