2 Replies Latest reply on Jun 26, 2010 12:24 AM by net7runner

    Using SWCs generated in the Flash IDE as RSLs?


      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?