Con BitmapData, quiero pegar 2 imágenes externas, las imágenes ya las cargué en un BitmapData cada una. Mi problema es cuando quiero usar copyPixels para copiar la segunda imagen (es un png con transparencias) sobre la primera, la primer imagen se sobreescribe y queda eliminada y lo que quiero es combinar las imágenes.
Algo curioso es que cuando cargo las imágenes desde la biblioteca, no tengo ningún porblema y me lo hace correctamente, pero el caso es que tienen que ser imágenes externas.
Les muestro los códigos.
Éste es el que carga las imagenes desde la biblioteca
Código :
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
var bitmapData_1:BitmapData = BitmapData.loadBitmap("imagen1");
var bitmapData_2:BitmapData = BitmapData.loadBitmap("imagen2");
var mc_1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc_1.attachBitmap(bitmapData_1, this.getNextHighestDepth());
bitmapData_1.copyPixels(bitmapData_2, new Rectangle(0, 0, 200, 376), new Point(0, 0));Y este es el que carga las imagenes exteriores pero no las combina (este es el que necesito arreglar)
Código :
import flash.display.BitmapData;
import flash.geom.*;
import flash.filters.*;
this.createEmptyMovieClip ("imagen1",this.getNextHighestDepth());
this.createEmptyMovieClip ("imagen2",this.getNextHighestDepth()); imagen2._x = 201;
this.createEmptyMovieClip ("imagen3",this.getNextHighestDepth()); imagen3._x = 401;
foto1Listener = new Object();
foto2Listener = new Object();
foto3Listener = new Object();
img1 = new BitmapData(200, 376);
img2 = new BitmapData(200, 376);
img3 = new BitmapData(200, 376);
imagen3.attachBitmap(img3,this.getNextHighestDepth());
cargador1 = new MovieClipLoader();
cargador1.addListener(foto1Listener);
cargador1.loadClip("foto.jpg", imagen1);
cargador2 = new MovieClipLoader();
cargador2.addListener(foto2Listener);
cargador2.loadClip("marco.png", imagen2);
foto1Listener.onLoadInit = function(imagen1){
img1.draw(imagen1);
img3.copyPixels(img1, new Rectangle(0, 0, 200, 376), new Point(0, 0));
}
foto2Listener.onLoadInit = function(imagen2){
img2.draw(imagen2);
img1.copyPixels(img2, new Rectangle(0, 0, 200, 376), new Point(0, 0));
}
Saludos.
