# All remove or no remove

**URL:** <https://forum.kirupa.com/t/all-remove-or-no-remove/306743>\
**Category:** Uncategorized\
**Created:** [March 21, 2010, 6:40pm UTC](https://forum.kirupa.com/t/all-remove-or-no-remove/306743 "2010-03-21T18:40:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackout188](https://avatars.discourse-cdn.com/v4/letter/b/dec6dc/32.png) [@blackout188](https://forum.kirupa.com/u/blackout188)\
**Post date:** [March 21, 2010, 6:40pm UTC](https://forum.kirupa.com/t/all-remove-or-no-remove/306743/1 "2010-03-21T18:40:04Z")

</div>

This is the code for my rotating menu in scene two，the problem description is in below

//Save the center coordinates of the stage  
var centerX:Number = stage.stageWidth / 2;  
var centerY:Number = stage.stageHeight / 2;  
var NUMBER\_OF\_ITEMS:uint = 11;  
//Radius of the menu circle (horizontal and vertical)  
var radiusX:Number = 200;  
var radiusY:Number = 100;  
//Angle difference between the items (in radians)  
var angleDifference:Number = Math.PI \* (360 / NUMBER\_OF\_ITEMS) / 180;  
//How fast a single circle moves  
var angleSpeed:Number = 0;  
//Scaling speed of a single circle  
var scaleSpeed:Number = 0.0002;  
//This vector holds all the items  
var itemVector:Vector.\<Item\> = new Vector.\<Item\> ;  
//This loop creates the items and positions them  
//on the stage  
for (var i:uint = 0; i \< NUMBER\_OF\_ITEMS; i++) {  
//Create a new menu item  
var item:Item = new Item();

//Get the angle for the item (we space the items evenly)  
var startingAngle:Number = angleDifference\*i;  
//Set the x and y coordinates  
item.x = centerX + radiusX \* Math.cos(startingAngle);  
item.y = centerY + radiusY \* Math.sin(startingAngle);  
//Save the starting angle of the item.  
//(We have declared the Item class to be dymamic. Therefore,  
//we can create new properties dynamically.)  
item.angle = startingAngle;

//Allow no mouse children  
item.mouseChildren = false;  
//Add the item to the vector  
itemVector.push(item);  
//Add the item to the stage  
addChild(item);  
//Add an item number to the item’s text field  
if(i==1){  
item.itemText.text = “1970”;  
item.addEventListener(MouseEvent.CLICK,y1970);  
function y1970(event:MouseEvent):void {  
gotoAndPlay(1,“y1970”);  
parent.removeChild(this);  
}  
}  
else if(i==2){  
item.itemText.text=“1975”;  
item.addEventListener(MouseEvent.CLICK,y1975);  
function y1975(event:MouseEvent):void {  
gotoAndStop(1,“y1975”);  
parent.removeChild(this);  
}  
}

else if(i==3){  
item.itemText.text=“1980”;  
item.addEventListener(MouseEvent.CLICK,y1980);  
function y1980(event:MouseEvent):void {  
gotoAndStop(1,“y1980”);  
parent.removeChild(this);  
}  
}  
else if(i==4){  
item.itemText.text=“1985”;  
item.addEventListener(MouseEvent.CLICK,y1985);  
function y1985(event:MouseEvent):void {  
gotoAndStop(1,“y1985”);  
parent.removeChild(this);  
}  
}  
else if(i==5){  
item.itemText.text=“1990”;  
}  
else if(i==6){  
item.itemText.text=“1995”;  
}  
else if(i==7){  
item.itemText.text=“2000”;  
}  
else if(i==8){  
item.itemText.text=“2005”;  
}  
else if(i==9){  
item.itemText.text=“2010”;  
}  
else if(i==10){  
item.itemText.text=“2015”;  
}  
else{  
item.itemText.text=“2020”;  
}

}  
//We use ENTER\_FRAME to animate the items  
addEventListener(Event.ENTER\_FRAME, enterFrameHandler);  
//This function is called in each frame  
function enterFrameHandler(e:Event):void {  
//Calculate the angle speed according to mouse position  
angleSpeed = (mouseX - centerX) / 5000;  
//Loop through the vector  
for (var i:uint = 0; i \< NUMBER\_OF\_ITEMS; i++) {  
//Save the item to a local variable  
var item:Item = itemVector\*;  
//Update the angle  
item.angle += angleSpeed;  
//Set the new coordinates  
item.x = centerX + radiusX \* Math.cos(item.angle);  
item.y = centerY + radiusY \* Math.sin(item.angle);  
//Calculate the vertical distance from centerY to the item  
var dy:Number = centerY - item.y;  
//Scale the item according to vertical distance  
item.scaleY = (dy / radiusY);  
//If we are above centerY, double the y scale  
if (item.y\<centerY) {  
item.scaleY \*= 2;  
}  
//Set the x scale to be the same as y scale  
item.scaleX = item.scaleY;  
//Adjust the alpha according to y scale  
item.alpha = item.scaleY + 1.1;  
}

}

The part I’m having problem with is

if(i==1){  
item.itemText.text = “1970”;  
item.addEventListener(MouseEvent.CLICK,y1970);  
function y1970(event:MouseEvent):void {  
gotoAndPlay(1,“y1970”);  
parent.removeChild(this);  
}

It will only display the background when my flash jump into the scene y1970  
everything else disappeared. So I tried parent.removeChild(item), the object item is stays in the scene of y1970 and not removed but everything on 1970 is there. Does anyone know how to fix it?
