Código PHP:
package cfx.Efectos{
import flash.events.*;
import flash.display.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import cfx.CfxEvent.*;
public class FxAgua extends MovieClip {
private var Ancho:Number;
private var Alto:Number;
private var FondoA;
private var FondoB;
private var PunOrig;
private var Contenedor;
private var Ola;
private var Agua;
private var Onda:DisplacementMapFilter;
private var Bmp:Bitmap;
private var Bmpx:Bitmap;
private var twTime=0;
private var twTimeTotal=0;
private var twTimeCont=0;
private var _Mc:MovieClip=new MovieClip();
private var Imagen:BitmapData;
private var ImagenTemp;
private var _INT;
public var func:Function = function (t:Number, b:Number, c:Number, d:Number):Number { return c*t/d + b; };
public function FxAgua(ImagenBD:BitmapData ,INT:Number=1,McContenedor:MovieClip=null):void {
ImagenTemp=ImagenBD;
_INT=INT;
if (McContenedor is MovieClip) {
_Mc=McContenedor;
}
addChild(_Mc);
Imagen=ImagenBD;
Ancho= Imagen.width;
Alto =Imagen.height;
FondoB = new BitmapData(Ancho,Alto, false,0);
FondoA= new BitmapData(Ancho,Alto);
PunOrig = new BitmapData(Ancho,Alto, false,128);
Contenedor = new BitmapData(Ancho,Alto, false,128);
Ola = new ConvolutionFilter(3,3,[1,1,1,1,1,1,1,1,1],9,0);
Agua = new ColorTransform(0,0,0.996,1,0,0,2,0);
Onda = new DisplacementMapFilter(FondoA,new Point(),4,4,_INT,_INT,"ignore");
Bmp= new Bitmap(FondoB);
Bmpx= new Bitmap(ImagenTemp);
_Mc.addChild(Bmp);
_Mc.addChildAt(Bmpx,0);
}
private function InicioEfect(event:Event) {
FondoA.applyFilter(PunOrig,new Rectangle(0, 0, Ancho,Alto),new Point(),Ola);
FondoA.draw(FondoA,new Matrix(),null,"add");
FondoA.draw(Contenedor,new Matrix(),null, "subtract");
FondoA.draw(FondoA, new Matrix(),Agua);
FondoB.applyFilter(Imagen,new Rectangle(0,0,Ancho,Alto), new Point(),Onda);
Contenedor = PunOrig;
PunOrig = FondoA.clone();
Onda.scaleX=_INT;
Onda.scaleY=_INT;
}
private function PuntoOnda(PX=NaN,PY=NaN):void {
var XM = PX;
var YM = PY;
PunOrig.setPixel(XM+1,YM,0);
PunOrig.setPixel(XM-1,YM,0);
PunOrig.setPixel(XM,YM+1,0);
PunOrig.setPixel(XM,YM-1,0);
PunOrig.setPixel(XM+1,YM+1,0);
PunOrig.setPixel(XM-1,YM-1,0);
}
private function protoTween(event:Event):void {
if (twTimeCont>twTimeTotal) {
_Mc.removeEventListener(Event.ENTER_FRAME,protoTween);
twTimeCont=0;
reset()
}
Bmp.alpha=func(twTimeCont,1,0-1,twTimeTotal);
twTimeCont++;
}
public function start() {
_Mc.addChildAt(Bmpx,0);
_Mc.addEventListener(Event.ENTER_FRAME,InicioEfect);
point();
}
public function Stop() {
_Mc.removeEventListener(Event.ENTER_FRAME,InicioEfect);
}
public function reset() {
_Mc.removeEventListener(Event.ENTER_FRAME,InicioEfect);
_Mc.addChildAt(Bmp,0);
}
public function point(X=NaN,Y=NaN) {
PuntoOnda(X,Y);
}
public function Fin(Tiempo,func) {
twTimeTotal=Tiempo;
_Mc.addEventListener(Event.ENTER_FRAME,protoTween);
}
public function increment(num:int) {
_INT=num;
}
}
}
Código PHP:
import cfx.Efectos.*
var MiBitmapData:BitmapData=new BitmapData(imagen.width,imagen.height,true,0)
MiBitmapData.draw(imagen)
var NuevoFXAgua=new FxAgua(MiBitmapData ,20,null)
addChild(NuevoFXAgua);
NuevoFXAgua.start()
addEventListener(MouseEvent.MOUSE_MOVE,hh)
addEventListener(MouseEvent.MOUSE_DOWN,re)
addEventListener(MouseEvent.MOUSE_UP,res)
function hh(e:Event){
NuevoFXAgua.point(mouseX,mouseY)
NuevoFXAgua.increment(mouseY/5)
}
function re (e:Event){
NuevoFXAgua.reset()
}
function res (e:Event){
NuevoFXAgua.start()