# Get var reference to instance of class from within

**URL:** <https://forum.kirupa.com/t/get-var-reference-to-instance-of-class-from-within/182152>\
**Category:** Uncategorized\
**Created:** [March 15, 2006, 8:37pm UTC](https://forum.kirupa.com/t/get-var-reference-to-instance-of-class-from-within/182152 "2006-03-15T20:37:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwopitz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jwopitz/32/1556_2.png) [@jwopitz](https://forum.kirupa.com/u/jwopitz)\
**Post date:** [March 15, 2006, 8:37pm UTC](https://forum.kirupa.com/t/get-var-reference-to-instance-of-class-from-within/182152/1 "2006-03-15T20:37:50Z")

</div>

Ⓜ

Ok, so basically I want to retrieve the var reference of an instance of a class from within the class. For example:

```
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000] **var** [/COLOR] ref:MyClass = [COLOR=#000000] **new** [/COLOR] MyClass [COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];

```

[COLOR=#808080]_//then via some method, I would like to get the var ref inside the class_[/COLOR]  
ref.[COLOR=#000080]getRef[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]_//returns “ref” instead of [object Object]_[/COLOR]  
[COLOR=#808080]_//_[/COLOR]  
[COLOR=#808080]_// or maybe even this_[/COLOR]  
[COLOR=#808080]_//_[/COLOR]  
[COLOR=#000000] **var** [/COLOR] ref:ClassA = [COLOR=#000000] **new** [/COLOR] ClassA COLOR=#000000[/COLOR];  
[COLOR=#000000] **var** [/COLOR] mgr:ClassB = [COLOR=#000000] **new** [/COLOR] ClassB COLOR=#000000[/COLOR];  
mgr.[COLOR=#000080]instance\_array[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR] = ref;  
mgr.[COLOR=#000080]getInstances[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]\*//returns “ref” instead of [object Object] \*[/COLOR]

[/LEFT]  
[/FONT]

You may ask why, well I want to do some spring cleaning inside this manager class I am making. Of course the above is a simplistic version of what I am trying to do.

:chinaman:
