Este es el código en el frame 1 del .fla
Código :
import flash.utils.Timer;
import flash.events.TimerEvent;
var tiempo:Timer = new Timer(100);
var inc:Number = 0;
tiempo.addEventListener(TimerEvent.TIMER, agregar);
tiempo.start();
function agregar(e:TimerEvent)
{
var circulo:Circulo = new Circulo();
circulo.nombrar("circulo"+inc++);
addChild(circulo);
circulo.cronometrar();
}
y esta la clase del movieclip en la librería:
Código :
package
{
import flash.display.MovieClip;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.geom.ColorTransform;
import flash.events.MouseEvent;
public class Circulo extends MovieClip
{
var nombrel:String = new String();
var texto:TextField = new TextField();
var formato:TextFormat = new TextFormat();
var indice:int = 0;
var letras:Array = new Array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
public function Circulo()
{
texto.embedFonts = true;
formato.color = 0x000000;
formato.size = 10 + Math.random()*32;
formato.font = "fertigo";
indice = Math.random()*40;
texto.text = letras[indice];
texto.setTextFormat(formato);
texto.autoSize = TextFieldAutoSize.LEFT;
addChild(texto);
this.y = 230*Math.random();
this.alpha = Math.random()/2;
var tx:Tween = new Tween(this, "x", Regular.easeOut, 0, 700*Math.random(), 1, true);
}
public function nombrar(nombrex:String)
{
nombrel = nombrex;
this.name = nombrel;
trace(this.name);
}
public function cronometrar()
{
var tiempo:Timer = new Timer(2000);
tiempo.addEventListener(TimerEvent.TIMER, desvanecer);
tiempo.addEventListener(TimerEvent.TIMER, quitar);
tiempo.start();
}
public function desvanecer(te:TimerEvent)
{
var ta:Tween = new Tween(this, "alpha", Regular.easeOut, this.alpha, 0, 3, true);
ta.addEventListener(TweenEvent.MOTION_FINISH, quitar);
}
public function quitar(te:TimerEvent)
{
trace("chau " + nombrel);
this.texto = null;
delete parent[nombrel];
trace(parent[nombrel].name);
}
}
}Una última pregunta: cuando se extiende de MovieClip no se pueden pasar parámetros al constructor?? he intentado hacerlo pero no funcionó. Muchas gracias desde ya.
