i wonder if library loading is all that important. What i mean is, code
itself is much smaller then resources&xml, the two things that will be
largest in size. If you defer loading resources until you need them,
does it really matter if you had five times as much code - proviso that
you are still only instantiating a reasonable amount, no matter how much
code is "on-deck" ready to run? Is that view accurate?
P T Withington wrote:
Each class that you created with
<class name="foo" ...
can be found and destroyed by:
lz['foo'].destroy();
delete lz['foo'];
The section in the developer's guide is telling you the steps you would have to
do if you wanted to unload a library. I know some users have succeeded in
this, but it is quite difficult. What Henry is telling you is that the system
does nothing to help you with your 3 tasks. The loadable libraries were
designed to help large applications only bring in what they needed, when they
needed it, but no effort has gone in to making it easy to unload them...
Especially important is that if you store _any_ references to classes or
instances defined in the library elsewhere in your program, you are responsible
for finding them and nulling them out. Otherwise they destroyed classes and
instances will never get collected by the garbage collector (and memory will
grow every time you re-load the library).
On 2009-12-22, at 19:35, Jonathan Shinn wrote:
Thanks, James. I'm actually saying that I get no errors in swf9 when running in
the developer's console with Debug turned on.
I suspect that your guess may be correct. At least, it seems to describe the
behavior that I'm seeing. I have tried actually destroying the classes, etc.
within the library, but can't seem to find a syntax that works.
Thanks for your input,
Jonathan
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of jamesr
Sent: Tuesday, December 22, 2009 4:15 PM
To: Jonathan Shinn; [email protected]
Subject: Re: [Laszlo-user] Repeated loading and unloading of a library
Are you saying you have no errors when run in the browser (like normal?) or
have run the output swf in the standalone flash debugger and seen no errors in
swf9 at all?
I can guess that the error in swf8 is being thrown in 9 but you are not seeing
anything in the browser's debugger.
(http://www.adobe.com/support/flashplayer/downloads.html for the debugger if
you don't have it)
on the topic of guesses (I have not used the library feature) I wonder if the
library loads and unloads, then any class definitions in swf8
(as2) from that library are overwritten and that's okay. In swf9, it looks like
importing the same class twice is an error. But i have seen that error before,
and i don't recall now why. i might write later.
hope it helps.
Jonathan Shinn wrote:
Hello everyone,
I'm struggling with the code below. When compiled to swf8, the library
will load and unload repeatedly, but will provide the following error
message:
"ERROR: Redefining $lzc$class_helloworld from <helloworld> to
<helloworld> ".
When compiled to swf9 or swf10, the library will load and unload the
first time, but fails to load on later attempts. No error message is
provided in these runtimes.
I'm finding the information on deleting imported libraries in Chapter
15 of the developer's guide to be a bit hard to follow and no actual
coded example is given, so I imagine that I'm simply missing some
step. Can someone tell me what I'm doing wrong here?
Thanks,
Jonathan
***********************************************************
<canvas width="100%" height="600" proxied="false">
<attribute name="lib"/>
<button text="Load helloworld library"
onclick="helloworldimport.load()" />
<button x="150" text="Unload helloworld library"
onclick="canvas.lib.destroy();helloworldimport.unload()"/>
<import name="helloworldimport" href="helloworldimport.lzx"
stage="deferred" />
<handler name="onload" reference="helloworldimport">
Debug.write("helloworld imported!");
canvas.lib = new lz.helloworld(canvas, {'x': 40, 'y': 50});
</handler>
</canvas>
*******************************************
<library>
<class name="helloworld" extends="view" width="150" height="150"
bgcolor="#ccaaee">
<text fontsize="40" align="center" valign="middle" text="Hello"
/>
</class>
</library>
*******************************************************