home *** CD-ROM | disk | FTP | other *** search
- package net.xinterface.display
- {
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.DisplayObject;
- import flash.display.GradientType;
- import flash.display.SpreadMethod;
- import flash.display.Sprite;
- import flash.events.TimerEvent;
- import flash.geom.Matrix;
- import flash.geom.Point;
- import flash.utils.Timer;
-
- public class Reflection
- {
- private var reflectContainer:Sprite;
-
- private var timer:Timer;
-
- private var reflectBitmap:Bitmap;
-
- private var destiny:Bitmap;
-
- private var bounds:Point;
-
- private var source:DisplayObject;
-
- public function Reflection(param1:DisplayObject, param2:Bitmap = null, param3:Number = 0.5, param4:Number = 150, param5:Number = 0)
- {
- var _loc12_:Number = NaN;
- super();
- this.source = param1;
- this.bounds = new Point(this.source.width,this.source.height);
- this.destiny = param2;
- this.reflectBitmap = new Bitmap();
- this.reflectBitmap.bitmapData = new BitmapData(this.bounds.x,this.bounds.y,true,0);
- this.reflectBitmap.bitmapData.draw(this.source);
- this.reflectBitmap.cacheAsBitmap = true;
- this.reflectBitmap.scaleY = -1;
- this.reflectBitmap.y = this.reflectBitmap.height;
- var _loc6_:String = GradientType.LINEAR;
- var _loc7_:Array = [16777215,16777215];
- var _loc8_:Array = [param3,0];
- var _loc9_:Array = [0,param4];
- var _loc10_:String = SpreadMethod.REFLECT;
- var _loc11_:Matrix = new Matrix();
- if(param5 <= 0)
- {
- _loc12_ = this.bounds.y;
- }
- else
- {
- _loc12_ = this.bounds.y / param5;
- }
- _loc11_.createGradientBox(this.bounds.x,_loc12_,90 / 180 * Math.PI,0,0);
- var _loc13_:Sprite = new Sprite();
- _loc13_.graphics.beginGradientFill(_loc6_,_loc7_,_loc8_,_loc9_,_loc11_,_loc10_);
- _loc13_.graphics.drawRect(0,0,this.bounds.x,this.bounds.y);
- _loc13_.graphics.endFill();
- _loc13_.cacheAsBitmap = true;
- this.reflectBitmap.mask = _loc13_;
- this.reflectContainer = new Sprite();
- this.reflectContainer.addChild(this.reflectBitmap);
- this.reflectContainer.addChild(_loc13_);
- }
-
- public function Stop() : void
- {
- if(this.timer != null)
- {
- this.timer.stop();
- this.timer.removeEventListener(TimerEvent.TIMER,this.Render);
- this.timer = null;
- }
- }
-
- public function Play(param1:Number = 30) : void
- {
- this.Stop();
- this.timer = new Timer(param1);
- this.timer.addEventListener(TimerEvent.TIMER,this.Render);
- this.timer.start();
- }
-
- public function Render(param1:TimerEvent = null) : BitmapData
- {
- this.reflectBitmap.bitmapData.dispose();
- this.reflectBitmap.bitmapData = new BitmapData(this.bounds.x,this.bounds.y,true,0);
- this.reflectBitmap.bitmapData.draw(this.source);
- var _loc2_:BitmapData = new BitmapData(this.bounds.x,this.bounds.y,true,0);
- _loc2_.draw(this.reflectContainer);
- if(this.destiny)
- {
- this.destiny.bitmapData = _loc2_;
- }
- return _loc2_;
- }
- }
- }
-
-