# Add objectname to array

**URL:** <https://forum.kirupa.com/t/add-objectname-to-array/305412>\
**Category:** flash\
**Created:** [February 24, 2010, 10:02pm UTC](https://forum.kirupa.com/t/add-objectname-to-array/305412 "2010-02-24T22:02:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stingfury](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@Stingfury](https://forum.kirupa.com/u/Stingfury)\
**Post date:** [February 24, 2010, 10:02pm UTC](https://forum.kirupa.com/t/add-objectname-to-array/305412/1 "2010-02-24T22:02:40Z")

</div>

Sup guys.

Alright, so I’m trying to do this thing where I click and object on the stage, and then the idea would be to add the name of that object (a movieClip I guess?) to an array.

Right now, this is what I’ve got

```auto

eef_mc.addEventListener(MouseEvent.CLICK, addBeefToIngredients);

function addBeefToIngredients(event:MouseEvent):void
{
    ingredients.push("beef");
}

toString_mc.addEventListener(MouseEvent.CLICK, printIngredients);

function printIngredients(event:MouseEvent):void
{
    trace(ingredients.toString());
} 

```

But what I would like to have, is a setup that listens for clicks on a series of objects, and then adds the name of a particular one when that one is clicked; or else I’ll just end up with alot of semi-identical and hard-to-manage code.

Is it clarified enough?  
Else, tell me. I’d love to get hints on how to do this the smartest way.

Thanks.
