# AsBroadcaster in class

**URL:** https://forum.kirupa.com/t/asbroadcaster-in-class/169990
**Category:** flash
**Created:** [November 21, 2005, 9:11pm UTC](https://forum.kirupa.com/t/asbroadcaster-in-class/169990 "2005-11-21T21:11:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![panhead490](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@panhead490](https://forum.kirupa.com/u/panhead490)
#### Post date: [November 21, 2005, 9:11pm UTC](https://forum.kirupa.com/t/asbroadcaster-in-class/169990/1 "2005-11-21T21:11:40Z")

</div>

This url talks about using the AsBroadcaster: [http://www.kirupa.com/developer/actionscript/asbroadcaster2.htm](http://www.kirupa.com/developer/actionscript/asbroadcaster2.htm)

But senocular doesn’t address using it in .as file.

Here’s what I came up for an ImageLoader class I’m in the process of writing:

```auto

class ImageLoader {
	private var containerMC:MovieClip;
	private var depth:Number;
	private var width:Number;
	private var height:Number
	private var x:Number;
	private var y:Number;
	
	// Implemented by AsBroadcaster
	public var addListener:Function;
	public var removeListener:Function;
	public var broadcastMessage:Function;
	
	public function ImageLoader(targetMC:MovieClip, width:Number, height:Number, x:Number, y:Number) {
		AsBroadcaster.initialize(this);
		
		this.containerMC = targetMC.createEmptyMovieClip("containerMC", depth);
		this.depth = depth;
		this.width = width;
		this.height = height;
		this.x = x;
		this.y = y;
	}
	
	public function loadImage(pathToImage:String) {
		containerMC.loadMovie(pathToImage);
		this.broadcastMessage("loading", this);
	}
	
	public function getContainer():MovieClip {
		return containerMC;
	}
}

```

Just to get it to compile I had to add the:  
// Implemented by AsBroadcaster  
public var addListener:Function;  
public var removeListener:Function;  
public var broadcastMessage:Function;

Is there a better way of doing that? AsBroadcaster isn’t all that well documented…any insight on how to let Flash know those methods exist another way…or the best OOP way would be great.

Thanks =)
