Subj : Re: JS_ResolveStandardClass and my 'DOM' To : Bruce Wheaton From : Brendan Eich Date : Wed Sep 15 2004 02:07 pm Bruce Wheaton wrote: > I'd like to make my own object hierarchy, similar to Flash etc. I saw the > thread about lazy evaluation. Can I use this through a calling chain? Say I > want to use a function in a script: > > show.module3.cue5.GotoAndPlay("Start") > > The show object is the base of my tree (I don't think it needs to be the > global object, does it?) then module3 and cue5 are objects that I wouldn't > create unless needed. > > Can I do that? Sure. > Ideally, when the script compiles first, I would create the > objects as needed and root them. The objects are linked by property ids to containing objects, up to the global object, so you don't need to root anything. > So my global class has something called a 'resolve op' (which I haven't > tracked down yet) from which I call JS_ResolveStandardClass? And then again > for the child? JS_ResolveStandardClass is for Date, RegExp, etc. For your purposes, you need that global_resolve to define show when it is first resolved. The class for the show object should have a resolve hook that handles module3 (and any other such names), defining the id being resolved with value referring to the next object in the chain, cue5 -- but only if and when id == 'cue5' is passed into module_resolve. Thus you get lazy construction of a tree of objects. /be .