This url talks about using the AsBroadcaster: 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:
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 =)