This content has been marked as final. Show 4 replies
Tried another variation. Attached a "Symbol1" class to "Symbol1" in the Assets.fla library via the Property dialog, (see attached code). This resolves the two compiler errors but no instance of "Symbol1" ever appears when Movie.swf runs.
I read somewhere that earlier versions of the Flash Player may run into a case where the importing SWF may try to render symbols from the exporting SWF before they are loaded. Since, Movie.swf is 359 bytes and Assets.swf is 342 bytes, I wonder if that might be happening to me or is there a something more fundamentally wrong with my approach?
there is no linkage in as3. assign a class name to your shared asset, load the swf containing the shared asset using the loader class and use the "init" event of the loader's loadinfo property to trigger instantiation of your shared asset using the "new" constructor.
I wonder why Adobe even enables the "export for runtime sharing" checkbox if it doesn't do anything for AS3? This definately lead me down the wrong rabbit hole trying to get that approach to work.
Anyway, I made the suggested code changes to Movie.as (attached). Unchecked the "export for runtime sharing" box on Symbol1 in Assets.fla. Removed the Symbol1 import from Movie.fla. And, sure enough, the Symbol1 import now works. Thanks, kglad.
So in summary, the two points that I missed were:
Every exported symbol must have as associated class definition in a corresponding .as file. so that symbol can in imported using the AS3 "import" directive.Ignore the "Export for runtime sharing" mechanism entirely and use the Loader class instead.