DUPLICAR CUALQUIER TIPO DE OBJETO QUE SEA DISPLAY OBJECT EN ACTION SCRIPT 3.0.
function cloneMovieClip(source: MovieClip): * {
var instancia: MovieClip = new MovieClip();
instancia.transform = source.transform;
instancia.filters = source.filters;
instancia.cacheAsBitmap = source.cacheAsBitmap;
instancia.opaqueBackground = source.opaqueBackground;
instancia.graphics.copyFrom(source.graphics);
return instancia;
}
var Circulo: MovieClip = new MovieClip();
var colorLinea:uint = Math.random() * 0xffffff;
var colorFondo:uint = Math.random() * 0xffffff;
Circulo.graphics.lineStyle(1, colorLinea);
Circulo.graphics.beginFill(colorFondo);
Circulo.graphics.drawCircle(20, 20, 20);
var circulos: Array = new Array();
for (var i: uint = 0; i < 100; i++) {
circulos.push(cloneMovieClip(Circulo));
circulos[i].x = Math.random() * 500;
circulos[i].y = Math.random() * 400;
this.addChild(circulos[i]);
}
CLONAR MOVIECLIPS CON ACTION SCRIPT 3.0
Full Stack Software Developer.
Fundador de Kitaokatech y creador del ERP Hanbai.