Comunidad de diseño web y desarrollo en internet online

Problema con removeChild

Citar            
MensajeEscrito el 17 Sep 2010 10:03 pm
Como andan tengo un problema con el siguiente codigo.
La idea es que cuando se ejecute la funcion onChangePage remueva todos los cont creados con el for de la funcion addItems, pero no funciona solo borra uno.

Código :

var cont:MovieClip;
function addItems(startFrom:Number):void
{
    for (var i:Number = startFrom*maxItems; i < (startFrom+1)*maxItems; i++)
    {
        if (xml.channel.item[i] != undefined)
        {
            cont = new contenedor();
            var pubDate:String = xml.channel.item[i].pubDate;
            var autor:String = xml.channel.item[i].author;
            var mesaj:String = xml.channel.item[i].guid;
            cont.nombre.text = autor;
            cont.titulo.text = mesaj;
            cont.enlace.text = pubDate;
            cont.x = i*(cont.width+10);
            cont.y = stage.stageHeight / 2;
            this.addChild(cont);

        }
    }
}
function onChangePage(e:MouseEvent):void
{
    this.removeChild(cont);
}



Alguien sabe una solucion.
Saludos.

Por tachi

10 de clabLevel



 

firefox
Citar            
MensajeEscrito el 18 Sep 2010 02:03 am
Claro, porque los declaras dentro de un loop y cada referencia sobreescribe la anterior, para borrarlos todos deberías repetir el loop y usar removeChildAt para irlos quitando. Si es lo único que tienes en el escenario, puedes usar numChildren para quitar todo

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.