So to compile <import> libraries , the tag compiler currently
instantiates a new instance of ObjectWriter, which is in essence
a new instance of a Compiler/CompilationEnvironment. It then emits
script code for all the definitions in the <import>
library.

What I'm thinking of doing is having the ScriptCompiler have an option
to generate a <import> library, which will be an app
which has a method that you would call with the "lz" object, and it
will stuff definitions into it, like this

public class MyLibrary extends Sprite {

          public function MyLibrary() {
          }

          public function loadclasses(lz:Object, resourceLibrary:Object) {
          /////// *** EMITTED BY IMPORT COMPILER  *** ////////////////
          lz['button'] = $lzc$class_button;
          lz['swatchview'] = $lzc$class_swatchview;
          ...
          /////////////////////////////////////////////////////

          /////// *** EMITTED BY IMPORT RESOURCE COMPILER  *** ////////////////
          resourceLibrary['lzfocusbracket_topleft_rsrc'] = {ptype: "sr",
assetclass: __embed_lzasset_lzfocusbracket_topleft_rsrc, frames:
["lps/components/lz/resources/focus/focus_top_lft.png"], width: 7,
height: 7};

          /////////////////////////////////////////////////////

          }
      }

So I would add an API to the ObjectWriter which the tag compiler uses
every time it compiles a <class> or instance-class, which
stores the class name so it can be added to this list of 'exported' classes.

The same thing would apply to embedded resources found when compiling
the <import> library, which are really a special kind of class
declarations in AS3.

So, this would work for LZX classes. But it wouldn't account for any
classes that are written as straight Javascript, inside of <script>
blocks. Maybe
we need a compiler pragma for the user to declare a class name as
"exported", so it could be added to this list that is being created.
So you could say

#pragma exportClassAs=foobar
class foobar {
...

}

and it would get added to the list of things that are stuck into "lz",
or maybe declared as a global in the main app, or something like that.

The interstitial classes generated by the script compiler also
wouldn't get exported, but that it is a good thing, nobody should ever
see those anyhow.







-- 
Henry Minsky
Software Architect
[EMAIL PROTECTED]

Reply via email to