Skip to main content
August 26, 2009
Question

delete scrollPane source - removeChild doesn't work

  • August 26, 2009
  • 1 reply
  • 3372 views

Hello,

I'm creating one sprite named 'holder' and I'm adding childs to it.

finally I use sp.source = "holder";  NOTE: scrollPane is in stage, having instance name = sp, holder is AS created.

this works very good, but I need to on button press refresh data on holder.

So I want to complete remove holder, so my function can recreate it with new elements and then define scrollPane.source = "holder";

How can I do this?

var holder:Sprite = new sprite();

holder.name = "holder";

addChild(holder);  //  this adds holder to stage

//

// add elements to holder

//

sp.source = "holder";

button.addEventListenner(MouseEvent.CLICK, limpar_sp);

function limpar_sp(e:Event):void {

var rh:Sprite;
rh = Object(sp.content);
sp.removeChild(rh);

}

this fires an error, saying holder isn't a child of sp, witch is true, is stage child, but was used as source of holder.

Thanks

Pluda

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 26, 2009

there are quite a few problems with the code you posted.

but if you just want to remove the content from your scrollpane use:

sp.content=null;

August 26, 2009

using sp.content = null; I get

1059: Property is read-only.

kglad
Community Expert
Community Expert
August 26, 2009

oops, use the source property.