# Deleting objects from the Papervision Scene

**URL:** <https://forum.kirupa.com/t/deleting-objects-from-the-papervision-scene/264384>\
**Category:** Uncategorized\
**Created:** [June 25, 2008, 5:05pm UTC](https://forum.kirupa.com/t/deleting-objects-from-the-papervision-scene/264384 "2008-06-25T17:05:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![claudioguglieri](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@claudioguglieri](https://forum.kirupa.com/u/claudioguglieri)\
**Post date:** [June 25, 2008, 5:05pm UTC](https://forum.kirupa.com/t/deleting-objects-from-the-papervision-scene/264384/1 "2008-06-25T17:05:47Z")

</div>

Hello guys! I´ve got a basic problem with Papervision :\_ I´m trying to create and then delete planes from the scene. I was using 1.7 version until I noticed there were not destroy method inside the materials classes so this is my first attemp using Papervision 2.

What I have done to test it is using [Papervision2.com](http://Papervision2.com) Basic Interactive tutorial example. In this, I´m creating 50 planes in the stage and adding them the erase method onMouse Down, here is the code :

// Creating planes…

override protected function init3d():void  
{

ourMaterial.interactive = true;  
ourMaterial.doubleSided = true;  
ourOverMaterial.interactive = true;  
ourOverMaterial.doubleSided = true;

for(var i:Number=0; i\<50; i++){  
planeArray\* = new Plane(ourMaterial, 1000,1000, 2, 2);

default\_scene.addChild(planeArray\*);

planeArray\*.addEventListener( InteractiveScene3DEvent.OBJECT\_PRESS, \_onPress );

planeArray\*.x=Math.random()_800  
planeArray_.x=Math.random()_600  
planeArray_.z=Math.random()_10  
planeArray_.rotationX=Math.random()_360  
planeArray_.rotationY=Math.random()_360  
planeArray_.rotationZ=Math.random()\*360  
}

}

// OnPress Event…

private function \_onPress( e:InteractiveScene3DEvent ):void  
{  
trace(“before destroying plains numChildren is”,default\_scene.numChildren);

for(var i:Number=0; i\<planeArray.length; i++)  
{

ourMaterial.destroy();  
planeArray\*.removeEventListener( InteractiveScene3DEvent.OBJECT\_PRESS, \_onPress);

default\_scene.removeChild(planeArray\*);  
planeArray\*=null

}  
planeArray.splice(0, planeArray.length);

trace(“after destroying planes numChildren is”,default\_scene.numChildren);  
}

//end

My problem is that I really can´t delete the objects from the Scene, when I request numChildren it display the total amount of planes I placed into the scene. Does anyone know how can I delete objects from the stage? Any Ideas? I´d appreciate any comments.Thx in advance

By the way! I know maybe there would be problem using just one material and destroying it on the itteration, but anyway, I also tried with just one plane and I couldnt delete it :\_

Thx  
Best Regards  
Clau!
