源文件找不到了,反编了一份.
效果参见附件:
- package com.dante
- {
- import com.greensock.*;
- import flash.display.*;
- import flash.events.*;
- import flash.filters.*;
- import flash.geom.*;
- public class BitmapMotionEngine extends EventDispatcher
- {
- private var bitmapDataOld:BitmapData;
- private var bitmapDataNew:BitmapData;
- private var bitmapDataTarget:BitmapData;
- private var duration:Number = 1.5;
- private var tween:TweenLite;
- private var blurOld:BitmapData;
- private var blurNew:BitmapData;
- private var motionComplete:Boolean = true;
- public function BitmapMotionEngine()
- {
- return;
- }// end function
- public function startMotion(param1:BitmapData, param2:BitmapData, param3:BitmapData) : void
- {
- if (this.motionComplete)
- {
- this.bitmapDataNew = param2.clone();
- this.bitmapDataOld = param1.clone();
- this.bitmapDataTarget = param3;
- this.blurNew = this.bitmapDataNew.clone();
- this.blurNew.applyFilter(this.blurNew, this.blurNew.rect, new Point(), new BlurFilter(70, 70, 1));
- this.blurOld = this.bitmapDataOld.clone();
- this.blurOld.applyFilter(this.blurOld, this.blurOld.rect, new Point(), new BlurFilter(70, 70, 1));
- this.tween = TweenLite.to(this, this.duration, {onUpdate:this.update, onComplete:this.onMotionComplete});
- }
- return;
- }// end function
- private function onMotionComplete() : void
- {
- this.blurNew.dispose();
- this.blurOld.dispose();
- this.bitmapDataNew.dispose();
- this.bitmapDataOld.dispose();
- this.motionComplete = true;
- this.dispatchEvent(new Event(Event.COMPLETE));
- return;
- }// end function
- private function update() : void
- {
- var _loc_1:* = this.tween.currentTime / this.duration;
- var _loc_2:* = new ColorTransform(1, 1, 1, _loc_1);
- this.bitmapDataOld.merge(this.blurOld, this.bitmapDataNew.rect, new Point(), _loc_1 * 256, _loc_1 * 256, _loc_1 * 256, 256);
- this.blurNew.merge(this.bitmapDataNew, this.bitmapDataOld.rect, new Point(), _loc_1 * 256, _loc_1 * 256, _loc_1 * 256, 256);
- this.bitmapDataTarget.draw(this.bitmapDataNew, null, new ColorTransform(1, 1, 1, Math.pow(_loc_1, 2)));
- this.bitmapDataTarget.draw(this.bitmapDataOld, null, new ColorTransform(1, 1, 1, Math.pow(1 - _loc_1, 2)));
- return;
- }// end function
- }
- }