# Remove Array Elements from stage

**URL:** <https://forum.kirupa.com/t/remove-array-elements-from-stage/267332>\
**Category:** flash\
**Created:** [July 30, 2008, 7:50pm UTC](https://forum.kirupa.com/t/remove-array-elements-from-stage/267332 "2008-07-30T19:50:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![snobdr8](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@snobdr8](https://forum.kirupa.com/u/snobdr8)\
**Post date:** [July 30, 2008, 7:50pm UTC](https://forum.kirupa.com/t/remove-array-elements-from-stage/267332/1 "2008-07-30T19:50:30Z")

</div>

Hey Guys and Gals. I have the following code that duplicates a movie clip on my stage. At the end of my web banner I am having trouble making the movie clips disappear. It’s an online banner so when the banner loops I don’t want the duplicated clips to stay on the stage I just want them to clear off and have it start from scratch again. I’ve tried popping them through a function and the removeChild statement. Just stuck at the moment. Thanks!

//This array will hold all the rectangles on the stage  
var rectangles:Array = new Array();

//In this loop, we’ll create 50 rectangles  
for (var i = 0; i \< 25; i++) {

//Create one rectangle  
var rectangle:Rectangle = new Rectangle();

//Assign a random position  
rectangle.x = 15;  
rectangle.y = 85;

//Add the rectangle on to the stage  
addChild (rectangle);

//Add the rectangle to the array  
rectangles.push (rectangle);

}

//The timer will call the “shakeRectangles” function every 0.02 seconds  
var timer:Timer = new Timer(20, 100000000);  
timer.addEventListener (TimerEvent.TIMER, shakeRectangles);  
timer.start ();

//This function is responsible for animating the shake  
function shakeRectangles (e:Event):void {

//Loop through the array  
for (var i = 0; i \< 25; i++) {

```
//Rotate the rectangle a random amount (from -4 to 4) 
rectangles*.rotation += Math.random() * 1 - 0.5;

//Assign a new random position
rectangles*.x += Math.random() * 2 - 1;
rectangles*.y += Math.random() * 2 - 1;

```

}  
}
