Subj : Re: Namespaces To : netscape.public.mozilla.jseng From : Berserker Date : Tue Oct 11 2005 01:44 pm > That is not an example of namespaces, just an object, referenced by the > name core in the scope chain in which that line is evaluated, containing > another object, io, which contains a constructor function, File. Thanks for reply > You can do all of this with JS_DefineObject and JS_InitClass. Ok, that's what I did: // First create the global object JSObject *globalObject = JS_NewObject(g_context, &MyGlobalClass, 0, 0); // A simple package class JSClass Package::PackageClass = { "Package", JSCLASS_HAS_PRIVATE, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub }; // Then I create the package instance (web for example) JSObject *web_package = JS_DefineObject(g_context, globalObject, "web", &PackageClass, NULL, JSPROP_PERMANENT | JSPROP_READONLY); // Init the "Page" class under the web package JS_InitClass(g_context, web_package, NULL, &MyPageClass, MyPageConstructor, 0, NULL, NULL, NULL, NULL); // Then I declare others classes under the web package. JS_InitClass(g_context, web_package, NULL, &MyButtonClass, MyButtonConstructor, 0, NULL, NULL, NULL, NULL); JS_InitClass(g_context, web_package, NULL, &MyTextBoxClass, MyTextBoxConstructor, 0, NULL, NULL, NULL, NULL); This works great, and now I can write a sintax like this: var button = new web.Button(); but I still have a problem: I have a global variable called "document" of type "page" (defined under the global object): when I declare the page class under the global object everything works, but now that's it's declare under the web package no more callbacks are called. For example: var textbox = new web.TextBox(); // This works now page.controls.add(textbox); // Error! controls has no properties! Why?Before it worked... Help plz! (sorry for my english...) .