# Setting an Instance Name w/AS

**URL:** <https://forum.kirupa.com/t/setting-an-instance-name-w-as/327008>\
**Category:** flash\
**Created:** [January 30, 2012, 6:05pm UTC](https://forum.kirupa.com/t/setting-an-instance-name-w-as/327008 "2012-01-30T18:05:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheOtherTedium](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@TheOtherTedium](https://forum.kirupa.com/u/TheOtherTedium)\
**Post date:** [January 30, 2012, 6:05pm UTC](https://forum.kirupa.com/t/setting-an-instance-name-w-as/327008/1 "2012-01-30T18:05:55Z")

</div>

I’m new to this forum, etc. etc. looked at s.a.q., etc. etc. so forgive me if this, or any other questions, are often answered. I’ve looked a little, but can’t find anything.

Anywho, my question is pretty simple (I think):

I’m new to AS and am doing a test where I create shrapnel pieces from a grenade which explodes upon the user pressing a button.

Here’s my code so far:

```auto
import flash.events.MouseEvent;

btn1.addEventListener(MouseEvent.CLICK, createShrap);
function createShrap(e:MouseEvent):void
{
    source1.visible = false;
    for (var i:uint = 0; i < 10; i++)
    {
        var shrap:MovieClip = new Shrap();
        addChild(shrap);
        shrap.x = source1.x;
        shrap.y = source1.y;
    }
}

```

Source1 is the grenade image, and, of course, shrap is the many shrapnel coming out of it. What I want is to set velocity variables to the individual shraps being added, but I don’t know their individual instance names with which I can refer to them later on in the code. I expected something like “shrap1”, “shrap2” etc., but am pretty well confused here.

Could you tell me any of the following:  
[LIST]  
[_]How to set a new instance name to any MovieClip using Action Script  
[_]What are the instance names of the 10 MovieClips I have created?  
[_]When I type trace(shrap.instanceName) or trace(shrap.name), this doesn’t seem to be the same instance name with which I alter the MovieClip’s properties. Why is this?  
[_]Hence, what is the purpose of .instanceName and .name?  
[/LIST]

Thank you!
