Difference between revisions of "Namespace.js"
From LugdunonWiki
(Created page with "At the core of Lugdunon is the '''''Namespace''''' object. This object provides for an object oriented model in JS, as well as runtime code/class dependency resolution. It als...") |
Revision as of 17:28, 13 October 2013
At the core of Lugdunon is the Namespace object. This object provides for an object oriented model in JS, as well as runtime code/class dependency resolution. It also provides support for internationalization (i18n), asset loading, and local caching of assets.
Let’s take a look at what a simple class representing a 2dPoint (in net/lugdunon/math/TwoDPoint.js) would look like:
- Namespace.package("net.lugdunon.math");
- Namespace.newClass("net.lugdunon.math.TwoDPoint");
- net.lugdunon.math.TwoDPoint.prototype.init=function(initData)
- {
- this.x=initData.x;
- this.y=initData.y;
- return(this);
- };
- net.lugdunon.math.TwoDPoint.prototype.add=function(p)
- {
- if(p.instanceOf && p.instanceOf("net.lugdunon.math.TwoDPoint"))
- {
- this.x+=p.x;
- this.y+=p.y;
- }
- };