If you are like me when I first started using Javascript I was confused as to how to make a class. There are no classes or package declarations like there is in Actionscript. Turns out its pretty simple, lets take a look.
[javascript]
function MainClass( param1, param2 ){
this.param1 = param1;
this.param2 = param2;
this.build = function(){
/*
* treat this as your constructor
* does not need to be build, can name anything you would like
*/
}
this.doSomething( param ){
// an example of a method
}
this.build();
}
[javascript]
var Singleton = {};
Singleton.doSomething = function(){
/*
* your method that can be accessed from anywhere
*/
}
[javascript]
Singleton.doSomething();