# Communication Between Variables in Other Classes?

**URL:** <https://forum.kirupa.com/t/communication-between-variables-in-other-classes/323813>\
**Category:** Uncategorized\
**Created:** [July 19, 2011, 4:16pm UTC](https://forum.kirupa.com/t/communication-between-variables-in-other-classes/323813 "2011-07-19T16:16:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scheisse](https://avatars.discourse-cdn.com/v4/letter/s/839c29/32.png) [@Scheisse](https://forum.kirupa.com/u/Scheisse)\
**Post date:** [July 19, 2011, 4:16pm UTC](https://forum.kirupa.com/t/communication-between-variables-in-other-classes/323813/1 "2011-07-19T16:16:21Z")

</div>

Okay I have a problem here that is probably basic for most of you. I need to know how to reference variables in other classes. I have been avoiding this by referencing variables from the Main class, where they are created. But at this point I would like to be able to have the option and it would make me a better programmer.

Say I create a movieclip in the **Main.as**

```auto

public var Enemy_mc:Enemy = new Enemy();
addChild(Enemy_mc);

```

Now in another .as file, **Background.as** I want to tell the Enemy to move to the right:

```auto

Enemy_mc.x += 5;

```

How do I do that^ without creating a variable in Main.as and having it check Background.as for variable updates?

Can I do something like “ **Main.Enemy\_mc += 5;** ” like I can do in Main.as to variables that I have created in Main in other classes?

Thanks!
