I’m trying to learn OO as it applies to Javascript and apply it to some of my bloated procedural libraries. I’m not sure i’m quite grasping it though. Here’s a simplified (for my benefit as much as yours) view of what i’m trying to do with a class for video player controls. Does this syntax even work?? Is there a better approach for this? I figured this would be more efficient than doing an if/else statement or switch statement for every control instance…I’m not a trained developer so if you take a stab at this make sure you leave out jargon and theory as much as possible or it will blow over my head at 30,000 ft ?
[code]
function Controls(iPluginType) {
this.pluginType=iPluginType; // 0-Windows Media, 1-RealPlayer, 2-QuickTime
this.playMovie=new Array(
/* function to play Windows Media movie */,
/* function to play RealPlayer movie */,
/* function to play QuickTime movie */
);
this.stopMovie=new Array(
/* function to stop Windows Media movie */,
/* function to stop RealPlayer movie */,
/* function to stop QuickTime movie */
);
if(typeof Controls.initialized==’undefined’){
Controls.prototype.play=function(){
this.playMovie[this.pluginType];
}
Controls.prototype.stop=function(){
this.stopMovie[this.pluginType];
}
Controls.initialized=true;
}
}