# How to "attach" a class to an object

**URL:** <https://forum.kirupa.com/t/how-to-attach-a-class-to-an-object/321859>\
**Category:** flash\
**Created:** [May 3, 2011, 3:26pm UTC](https://forum.kirupa.com/t/how-to-attach-a-class-to-an-object/321859 "2011-05-03T15:26:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![m2244](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@m2244](https://forum.kirupa.com/u/m2244)\
**Post date:** [May 3, 2011, 3:26pm UTC](https://forum.kirupa.com/t/how-to-attach-a-class-to-an-object/321859/1 "2011-05-03T15:26:27Z")

</div>

So let’s say that the user drags four instances of an object on stage (this is an object from the library). Now when the user clicks on one of these objects I want to “attach” a class to that object so that it has its own variables that will stay associated with that object. Then when the user clicks on one of the other objects, that class is “attached” to it.

I am trying to associate arrays or maybe dictionaries with these objects on stage.

Is it simply something like this when the user clicks on one of the objects:

```auto

funtion handleClick(evt:MouseEvent):void
{
    evt.currentTarget = variableStorageClass();
}

```

And then pass it the information for the variables/arrays?

Also, how do you retrieve the variables when you need them?
