Hi all, not sure of the best way to approach this.
I'm working with a pure Actionscript project in FB4. I have a bunch of UI artwork authored in the Flash IDE. I compile all of them into an SWC and then add code to them by extending them with another class, e.g.:
(in art.swc, generated from art.FLA)
assets.Foo_display extends Sprite
(in main project)
class Foo extends Foo_display
// add code behavior here
Now, this works fine as long as I include art.swc as a normal library (i.e. "Merged into code" in the project properties). However, what I really want is for art.swc to be an RSL that I load dynamically. However, FB4 doesn't let me mark the SWC as an RSL, just as an "external library."
That's all fine and good - I know how to manually load art.swf at runtime. However, here's a problem: my main project (which compiles into main.swf) contains a class definition which depends on Foo_display. When I run main.swf I get a VerifyError because (I believe) Foo_display isn't loaded into the ApplicationDomain yet. Crap!
So, do I have to write a preloader to load art.swf before I even think about running main.swf? The whole point here was to be able to delay loading art.swf for a little while. I don't know much about RSLs, but I'm under the impression that they don't have this restriction (i.e. the player will go ahead and verify the swf and let you worry about loading the actual code before you use it). Is this true?
Interesting side-note: the verifier doesn't seem to care about instances of classes, just inheritance trees. Thus, in main.swf I can create instances of Foo_display all I want and the system doesn't complain as long as I've loaded art.swf into the current ApplicationDomain before I do so. However, if I have any classes that inherit from Foo_display - BAM, VerifyError. Anyone know why this is?
RSLs do not get any special treatment from the player. I think the VerifyError from missing inheritance dependencies is part of the VM and is described here in chapter 3, http://www.adobe.com/devnet/actionscript/articles/avm2overview.pdf.
So from what I understand from reading the spec, when the VM loads any SWF it goes through a preliminary verification process which, among other things, makes sure that every class, and all of its ancestors have been defined. However, the verifier doesn't check much of anything else, including class members, variables created on the stack, or, most surprisingly, static class members. Nuts to my original plan, but things make sense now. Thanks!