# My adventures in AS2.0

**URL:** <https://forum.kirupa.com/t/my-adventures-in-as2-0/147714>\
**Category:** Uncategorized\
**Created:** [May 13, 2005, 1:10am UTC](https://forum.kirupa.com/t/my-adventures-in-as2-0/147714 "2005-05-13T01:10:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riddler](https://avatars.discourse-cdn.com/v4/letter/r/e56c9b/32.png) [@Riddler](https://forum.kirupa.com/u/Riddler)\
**Post date:** [May 13, 2005, 1:10am UTC](https://forum.kirupa.com/t/my-adventures-in-as2-0/147714/1 "2005-05-13T01:10:56Z")

</div>

Ok I have a pretty interesting situation… I am trying to use Flash’s BroadcasterMX class to create personalized “onWhatever” listeners for my classes. I got on this rabbit trail by picking apart some of flash’s included classes _cough_ Tween _cough_… Along with this post is a class I created in order to simulate my own listeners. I will paste the code as well because it is rather short. I am also aware of an ASBroadcaster class (talked about [http://www.kirupa.com/developer/actionscript/asbroadcaster2.htm](http://www.kirupa.com/developer/actionscript/asbroadcaster2.htm)) but just ended up fooling with the BroadcasterMX because that was used in these others as talked about above…

This is my test class:

```auto

import mx.transitions.BroadcasterMX;

class Kingdom {
	
	static var __initBroadcaster = BroadcasterMX.initialize (Kingdom.prototype, true);
	
	public var addListener:Function;
	public var removeListener:Function;
	public var broadcastMessage:Function;
	
	private var _listeners:Array;
	
	public function Kingdom() {
		this._listeners = [];
		this.addListener (this);
	}
	
	public function birthKing(name:String):Void {
		var King:MovieClip = _root.createEmptyMovieClip(name, 0);
		this.broadcastMessage("onKingBorn", this);
	}
	
}

```

and here is its usage:

```auto

var myKingdom:Kingdom = new Kingdom();
myKingdom.birthKing("King_Richard");
myKingdom.onKingBorn = function() {
	trace("A king was born!");
}

```

my problem is that it errors and says “No such property: onKingBorn”… Obviously I am doing something wrong, but my review of its usage in the Tween class proves unhelpful :(… any help?

here is the source for your convienence: [http://iamvery.com/Random\_Files/testClass.zip](http://iamvery.com/Random_Files/testClass.zip)
