Busy with the holidays, work, and possibly buying a new home, so I have neglected everyone...I appologize :).
Most components (including the macromedia components) fail to provide defaults for component parameters. Forcing you to pass in an ugly initObj into attachMovie which usually requires you to look at the component definition to find the variable names. I hate this :). To solve this and make your code readable and concise in the proccess, define all member variables in the prototype object.
MyClass = function(){
}
Object.registerClass("MySymbol",MyClass);
MyClass.prototype.memberVar = "string";
MyClass.prototype.enabled = true;
MyClass.prototype.selectionType = "single";
Just a simple tip that a lot of people overlook. I always put member variables in the prototype, which is a good topic of debate. Many people prefer to define member variables in the constructor, which is required anyway for reference types. But any and all that I can define in the prototype object...I do.
This makes code more readable to me, as well as more straight forward to extend. The default will be there, this way I don't have to redefine these defaults before super is run, as well as call any methods that may go along with them (ie. setSelectionType(this.selectionType) )
PS I admit I had a few drinks before I wrote this, I appologize for glaring errors (such as spelling components wrong in the title)
11:35:28 PM
|