[Laszlo-dev] dynamic libraries and resources

Oliver Steele steele at laszlosystems.com
Mon Feb 14 08:14:22 PST 2005


On Feb 11, 2005, at 6:51 PM, Eric Bloch wrote:

> 1) When compiling to the Flash runtime, the LZX compiler will compile 
> in all resources that are declared inside a dynamically loaded library 
> into the including application.

On 13 Feb 2005, at 11:59, Henry Minsky wrote:

> Each snippet gets a new CompilationEnvironment and SWFWriter for it to
> compile with, but if we passed in a pointer to the main app
> compilation environment, it could be called into to place resources in
> the main app. I think basically it would involve adding a pointer to
> CompilationEnvironment to point to a "parent" compilation environment.

This sounds relatively straightforward.

However, a library compiled for 3.0 will only work with the application 
that it has been compiled for, because the generated names of anonymous 
resources (in <view resource=>) won't match anything else.  Here's an 
example of where this is a problem:

   app1:
   <canvas>
     <import href="lib.lzx" stage="defer"/>
   </canvas>

   app2:
   <canvas>
     <view src="image2.jpg"/>
     <import href="lib.lzx" stage="defer"/>
   </canvas>

   lib.lzx:
   <library>
     <view src="image.jpg"/>
   </library>

app1.lzx.swf will embed image.jpg with the name $LZ1, and will place a 
library lib.lzx.swf that refers to it by this name.
app2.lzx.swf will embed image.jpg with the name $LZ2, and will place a 
library lib.lzx.swf that refers to it by this name.

This is a problem if compiling app1 and app2 place lib.lzx.swf in the 
same location.  It means that after app1 has been compiled, app2 will 
display the wrong resources, and vice versa.

If app1.lzx and app2.lzx are in separate directories, last week's 
proposal that libraries are placed in a build subdirectory of the 
canvas source directory solves the problem.  However, app1.lzx and 
app2.lzx could be in the same directory and include the same file, as 
above, and then that proposal doesn't solve this problem.

Possibilities are:
A. Ignore the problem.  If the developer does this, they'll get a 
mysterious error.
B. Don't compile resources into the main app file.  Request them at 
runtime instead.
C. Add metadata that allows the application to detect when an 
application object file and a library object file don't match.
D. Place library object files in a unique location, where the location 
is determined by the name of the canvas file as well as its source 
directory.

(A) isn't acceptable.  (B) had other problems; we can go back to that 
if necessary, but I'd like to explore making Eric's proposal (1) above 
work.  (C) would be nice anyway but I don't see an easy way to 
implement it; so I recommend (D):

Compile a library file lib.lzx that is included by /path/to/canvas.lzx 
to /path/to/build/canvas/lib.lzx.swf.  This solves the problem above 
because, if app1.lzx and app2.lzx are in the same directory /path/to, 
compiling them results in the creation of two separate files, 
/path/to/build/app1/lib.lzx.swf and /path/to/build/app2/lib.lzx.swf.



More information about the Laszlo-dev mailing list