Hi there i want to do the following: make an instance on my stage a broadcaster, create a class called “Module”, in this class define the object as a listener, connect the class to an object on my stage or library.
Here’s what i have:
AsBroadcaster.initialize(Main_Md);
//class definition
Module = function(){
Main_Md.addListener(this);
function LoginMessage(){
this._visible=false;
}
};
Module.prototype = new MovieClip();
Object.registerClass("module3", Module);
And i have a button with the action
on (press) {
_root.Main_Md.broadcastMessage("LoginMessage");
}
Why doesnt this work? the object in the library has module3 as linkage, so that cant be the problem…help please
you cant yous function functionName(){} syntax to define functions if you’re within the block of another function. You’d need to use functionName = function(){}. Thats most of the problem, though with that you should be defining LoginMessage as a prototype function and not within the Module constructor.
Module = function(){
Main_Md.addListener(this);
};
Module.prototype = new MovieClip();
Module.prototype.LoginMessage = function (){
this._visible = false;
}
… also, you’re adding and removing modules a lot, you’d want to rewrite removeMovieClip for them to also remove them from Main_Md’s listener list.