# Simple Classes question

**URL:** <https://forum.kirupa.com/t/simple-classes-question/244451>\
**Category:** Uncategorized\
**Created:** [November 18, 2007, 10:08am UTC](https://forum.kirupa.com/t/simple-classes-question/244451 "2007-11-18T10:08:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerryj](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@jerryj](https://forum.kirupa.com/u/jerryj)\
**Post date:** [November 18, 2007, 10:08am UTC](https://forum.kirupa.com/t/simple-classes-question/244451/1 "2007-11-18T10:08:37Z")

</div>

Hi,

I made a simple example of three classes, because I keep running into the same problem again and again. Suppose you have two MovieClips in the library with the linkages Circle and Rect. And both of them have their own custom class. My problem is that I don’t know how to ‘communicate’ between those classes. Here is the example (it doesn’t have all the code I have tried sofar :-)):

Main.as:

```auto
 
package{
 
 import flash.display.Sprite
 
 public class Main extends Sprite{
 
  private var circle:Circle;
  private var rect:Rect;
 
  public function Main(){
 
   circle= new Circle();
   addChild (circle);
   rect= new Rect();
   addChild(rect);
   rect.x=300;
 
  }
 }
}

```

Circle.as:

```auto
 
package{
 
 import flash.display.Sprite
 import flash.events.MouseEvent
 
 public class Circle extends Sprite{
 
  private var rect:Rect;
 
  public function Circle(){
   addEventListener(MouseEvent.CLICK, clickCircleListener);
  }
 
  private function clickCircleListener(e:MouseEvent):void{
   trace(e.target);
 
   //how can I address 'rect' from here?
   trace(rect)//trace null
   trace(this.parent.rect);//rect is undefined property
   //for instance, how can I make 'rect' invisible?
 
  }
 
 }
}

```

Rect.as:

```auto
 
package{
 
 import flash.display.Sprite
 import flash.events.MouseEvent
 
 public class Rect extends Sprite{
 
  public function Rect(){
   addEventListener(MouseEvent.CLICK, clickRectListener);
  }
 
  private function clickRectListener(e:MouseEvent):void{
   trace(e.target);
  }
 }
}

```

Or is it not the way to go to communicate between classes like this?

thanks!

Jerryj.
