# AS2: broadcaster / listeners in OOP? (class / class)

**URL:** <https://forum.kirupa.com/t/as2-broadcaster-listeners-in-oop-class-class/231850>\
**Category:** flash\
**Created:** [July 8, 2007, 10:15pm UTC](https://forum.kirupa.com/t/as2-broadcaster-listeners-in-oop-class-class/231850 "2007-07-08T22:15:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aesir](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@Aesir](https://forum.kirupa.com/u/Aesir)\
**Post date:** [July 8, 2007, 10:15pm UTC](https://forum.kirupa.com/t/as2-broadcaster-listeners-in-oop-class-class/231850/1 "2007-07-08T22:15:31Z")

</div>

I want to know how to **make class instances into listeners and broadcasters, from inside each class.** Here is what I am trying specifically…

part of the Proj class… (projectiles, as a matter of fact)

```auto

private function listen():Void {
     u.register(this);
     **onUpdate** = function(){ 
        step(); // a function I have which makes the projectile move (not shown)
     }
 }

```

where “u” is another class, the _Updater_ class with this code…

```auto
 class Updater {
 
 // const. --- make this a broadcaster
 public function Updater(){
  AsBroadcaster.initialize(this);
 }
 
 // function to add a projectile as a listener 
 // (in this case, called *by *projectiles)
 public function register( p:Proj ):Void {
  addListener( p );
 }
 
 // update all projectiles listening to the updater
 public function updateListeners():Void {
  broadcastMessage(" **onUpdate**"); 
 }
}

```

Problem is, I get a bunch of errors:

_[COLOR=darkred]There is no method with the name ‘addListener’.[/COLOR]_  
_[COLOR=darkred]addListener( p );[/COLOR]_

_[COLOR=darkred]There is no method with the name ‘broadcastMessage’.[/COLOR]_  
_[COLOR=darkred]broadcastMessage(“onUpdate”); [/COLOR]_

_[COLOR=darkred]There is no property with the name ‘onUpdate’.[/COLOR]_  
_[COLOR=darkred]onUpdate = function(){[/COLOR]_

Thanks in advance!

PS: What is the syntax for using AS2 code tags instead of just “[CODE|”?
