# Checking if an unnamed object exists

**URL:** <https://forum.kirupa.com/t/checking-if-an-unnamed-object-exists/304599>\
**Category:** flash\
**Created:** [February 10, 2010, 4:23pm UTC](https://forum.kirupa.com/t/checking-if-an-unnamed-object-exists/304599 "2010-02-10T16:23:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhjodokast](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bhjodokast/32/737_2.png) [@bhjodokast](https://forum.kirupa.com/u/bhjodokast)\
**Post date:** [February 10, 2010, 4:23pm UTC](https://forum.kirupa.com/t/checking-if-an-unnamed-object-exists/304599/1 "2010-02-10T16:23:29Z")

</div>

I have a name for the object, but it doesn’t seem to work.

Anyone know why this doesn’t work?

```auto

		if (sprite) {
			removeChild(sprite);
		} else {
			// there is no sprite.			
		}
		
		sprite = new Sprite();
		sprite.addChild(redRect);
		//sprite.x = numPositionToPlace;
		sprite.x = 106; //106 actual
		sprite.y = 546; //546 actual
		sprite.alpha = .5;
		addChild(sprite);

```

I can tell it’s not working because the box duplicates and the Alpha increases to mask above .5.

Or, how would I trace all objects that are in the container? Nothing is working like AS2… :shifty:
