El código es este:
Código :
Código PHP:
Ver original
// importamos las clases necesarias import flash.display.BitmapData; import flash.geom.Rectangle; import flash.geom.Point; MovieClip.prototype.distorsionar = function(distorsionV:Number, distorsionH:Number) { var transparent:Boolean = true; var fillColor:Number = 0x00000000; // objeto bitmapData donde almacenamos la info del clip a distorsionar var bitmap_1:BitmapData = new BitmapData(ancho, alto, transparent, fillColor); bitmap_1.draw(this); this._visible = false; distorsionado_mc.removeMovieClip(); distorsionado2_mc.removeMovieClip(); // clip donde crearemos la distorsión var contenedor:MovieClip = this._parent.createEmptyMovieClip("distorsionado_mc", this._parent.getNextHighestDepth(), {_x:this._x, _y:this._y}); var contenedor2:MovieClip = this._parent.createEmptyMovieClip("distorsionado2_mc", this._parent.getNextHighestDepth(), {_x:this._x, _y:this._y}); contenedor._x = this._x; contenedor._y = this._y; contenedor2._x = this._x; contenedor2._y = this._y; //Deformación horizontal for (var k:Number = 1; k<alto; k++) { var clip_temp:MovieClip = contenedor.createEmptyMovieClip("clip"+k, contenedor.getNextHighestDepth(), {_x:0, _y:k}); clip_temp._y = k; var bitmap_temp:BitmapData = new BitmapData(ancho, 1); bitmap_temp.copyPixels(bitmap_1,new Rectangle(0, k, ancho, k),new Point(0, 0)); clip_temp.attachBitmap(bitmap_temp,clip_temp.getNextHighestDepth(),"auto",true); clip_temp._xscale = ((k/(ancho-1))*(100-distorsionH))+distorsionH; clip_temp._x = (ancho-clip_temp._width)*0.5; } bitmap_1.dispose(); contenedor._visible = false; var bitmap_2:BitmapData = new BitmapData(ancho2, alto2, transparent, fillColor); bitmap_2.draw(contenedor); //Deformación vertical for (var l:Number = 1; l<ancho; l++) { var clip_temp:MovieClip = contenedor2.createEmptyMovieClip("clip"+l, contenedor2.getNextHighestDepth(), {_x:l, _y:0}); clip_temp._x = l; var bitmap_temp:BitmapData = new BitmapData(1, alto); bitmap_temp.copyPixels(bitmap_2,new Rectangle(l, 0, l, alto),new Point(0, 0)); clip_temp.attachBitmap(bitmap_temp,clip_temp.getNextHighestDepth(),"auto",true); clip_temp._yscale = ((l/(alto-1))*(100-distorsionV))+distorsionV; clip_temp._y = (alto-clip_temp._height)*0.5; } // liberamos memoria bitmap_2.dispose(); }; foto.miClip.loadMovie("pocoyo.jpg"); btn.onRelease = function(){ foto.distorsionar(50,50); } btn2.onRelease = function(){ foto.distorsionar(30,70); }
A ver si alguien puede echarme una mano. Gracias.