# Correct way to pass a reference?

**URL:** <https://forum.kirupa.com/t/correct-way-to-pass-a-reference/255607>\
**Category:** flash\
**Created:** [March 25, 2008, 8:53am UTC](https://forum.kirupa.com/t/correct-way-to-pass-a-reference/255607 "2008-03-25T08:53:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sceneshift](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sceneshift](https://forum.kirupa.com/u/sceneshift)\
**Post date:** [March 25, 2008, 8:53am UTC](https://forum.kirupa.com/t/correct-way-to-pass-a-reference/255607/1 "2008-03-25T08:53:49Z")

</div>

Hi,

Can someone please set me straight on how to communicate properly over different classes. Lets say I have two classes, one is “photo” and the other is “album”… in this instance, both classes are instantiated from my “main” class. Currently, in order to get “photo” to communicate (read variables, start methods) I’ve been setting them up in my main class like so:

```auto

public static var photoClass:photo = new photo();
public static var albumClass:album = new album();

```

And then inside of photo I would code:

```auto

main.albumClass.method();

```

This works fine, but I am told using static variables is a bad idea, and a better way to do it would be to pass each class as a reference, for example:

```auto

public static var photoClass:photo = new photo();
public static var albumClass:album = new album();

photoClass.init(albumClass);

```

Please help! I like using the first method, but if it’s bad then I’d rather get out of the habit now!

Thanks
