[Laszlo-dev] Fwd: some tantalizing comments about loading assetsfrom external swfs

Cortlandt Winters cort at notebookmargins.com
Mon Jan 10 06:15:30 PST 2005


Hi Henry,

I think that, as you suspect, the post is a little misleading here for your
purposes. He's not attaching the dynamically loaded library symbol to the
scope of the original loading timeline. He's just calling a function on the
scope of the loaded movieclip which can attach it's own library symbols and
be displayed as a result. This will work though.

So if you have Main.swf loading Assets1.swf Main can attach it's symbol's
dynamically and Assets1 can attach it's symbols dynamically, but Main can't
attach Assest1's symbols to it's scope, the best it can do is call a
function in Assets, have it attach a symbol to it's local scope and then
manipulate the Assets1.swf.

This obviously could create problems if you have 2 symbols from the
Assets1.swf that you are trying to manipulate simultaneously and
independently. You could duplicate the library swf, but that would be a
waste of memory for anything large, so I'm afraid lz would probably want to
load them each as independent swfs unless the assets are really small.

If you would like a simple example to look at I can create one either at
lunch or this evening if nobody does so before then.

-Cort

> -----Original Message-----
> From: laszlo-dev-bounces at openlaszlo.org
> [mailto:laszlo-dev-bounces at openlaszlo.org]On Behalf Of Henry Minsky
> Sent: Sunday, January 09, 2005 10:22 PM
> To: OpenLaszlo platform development and bug reporting
> Subject: [Laszlo-dev] Fwd: some tantalizing comments about loading
> assetsfrom external swfs
>
>
> This is a question addressed to anyone with Flash development expertise.
>
> We're looking at the issue of loading libraries or "modules" at
> runtime, using the  "loadMovie()" command,  and have been
> having been trying to figure out the right way to be allow the main
> app to access assets such as images which are defined inside of the
> runtime-loaded library (swf file).
>
> In LZX resources are declared as
>
>   <resource src="clock.jpg" name="gclock" />
>
> and the compiler will add this as a definition in the library swf
> file, creating an ExportAssets tag for it. The question is, how can we
> access these  library file definitions from the main app? The library
> swf file itself has been loaded via a loadMovie() call and attached to
> a special placeholder movieclip belonging to a LzLoader object.
>
>  In the guts of LzView, the code to attach a resource by name
> ultimately calls attachMovie() with the name of the resource.
>
> I saw the following user comments on the Macromedia docs site, where
> someone claims to be able to access the assets from a runtime-loaded
> movieclip. Their suggestion, as I understand it,  is to define a
> function which calls attachMovie but is defined as a methd on the
> library movieclip, and thus somehow has access to its flash dictionary
> namespace.
>
> I tried to do these steps by hand, but was still unable to attach
> image resources from the library file after it had been loaded. Does
> anyone know if the code mechanism described  below really ought to
> work ?
>
>
>
> ========================================
>
>
>
>
> http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimp
> l/common/html/wwhelp.htm?context=Flash_MX_2004&file=00001491.html
>
>
>
>      Yes, the linked clip MUST be in the library of the clip calling
> attachMovie.
>
>     The work arounds I've done usually include something like
> attaching a function to the clip that has the library item and having
> it attach to the other clip. IE:
>
>     // clip that wants the to do the attaching defines a generic
> function on the clip that has the item in it's library:
>
>     _level0.clipWIthLibraryItem.attachItem = function(target_mc, sName)
>     {
>     var mc:MovieClip = target_mc.attachMovie("linkageID", "newName",
> target_mc.getNextHighestDepth());
>     return mc;
>     }
>
>     var new_mc:MovieClip =
> _level0.clipWIthLibraryItem.attachItem(this, "newName");
>
>     this is off the top of my head, but I've done it serveral times.
> If you have questions, please email me: johng at acmewebworks.com
>
> JohnGrden said on Nov 5, 2004 at 7:48 AM :
>
>     you can't attach a dynamically created clip. what you probably
> need to do is create a class that creates your clips so that it can be
> called from anywhere you need it. You could even prototype a global
> function if need be:
>
>     _global.createClip = function(sNameOfClip, target_mc)
>     {
>     var mc:MovieClip = target_mc.createEmptyMovieClip(sNameOfClip,
> target_mc.getNextHighestDepth());
>     return mc;
>     }
>
>     questions: johng at acmewebworks.com
> _______________________________________________
> Laszlo-dev mailing list
> Laszlo-dev at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-dev



More information about the Laszlo-dev mailing list