# Class glue

**URL:** <https://forum.kirupa.com/t/class-glue/225403>\
**Category:** flash\
**Created:** [May 11, 2007, 1:16pm UTC](https://forum.kirupa.com/t/class-glue/225403 "2007-05-11T13:16:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dthought](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/dthought/32/3573_2.png) [@dthought](https://forum.kirupa.com/u/dthought)\
**Post date:** [May 11, 2007, 1:16pm UTC](https://forum.kirupa.com/t/class-glue/225403/1 "2007-05-11T13:16:43Z")

</div>

So we all know that AS3.0 shares the object oriented, class-based love. However, there’s one thing I’m not grasping fully and that is how to get two classes to talk to one another.

Let’s say I have a custom-made Debugger class, and its purpose is to store messages from the code (non-critical errors, such as which data item is being processed at a given point in time), with the potential to display it to a debug “log window”.

Now I have another custom-made class, let’s say Inventory, and in this case we want an instance of the Inventory class to log a message to an instance of the Debugger class.

```auto

var myDebugger:Debugger = new Debugger(stage.logWindow);
var myInventory:Inventory = new Inventory('fork', 'spoon', 'knife');

myInventory.retrieveItem([COLOR=#ff0000]'spoon'[/COLOR][COLOR=#000000])[/COLOR];

```

At that point, in this theoretical example, I would like the myInventory instance to log a debug message eg. “Inventory: Retrieving item ‘spoon’” or similar. However, how do I interact with the myDebugger class?

It is certainly a bad move to hard-code in the expectation that there be an instance of the debugger class called myDebugger.

Should I write a custom event listener? Should I use myInventory inside a try / catch / finally with a throw that is then passed to the myDebugger?

What is the best practice when getting two separate class instances to talk to one another?
