A few days ago Metal pointed out to me in a comment on my blog that by using the SWFs inside a SWC, my RSLs are much larger than they need to be. Sure enough he was right. When you use compc to create a SWC, the SWF inside the SWC contains a lot of unnecessary stuff when used as an RSL. That stuff is necessary to create an application which uses the SWC, so don’t go ditching compc. Here is what you need to do if you want to have size optimized RSLs:
- Create an ActionScript class that extends Sprite and includes references to the stuff you want to go into your RSL. For instance:
- Compile your SWC:
- Compile your RSL:
- Compile your application:
Upload app.swf and my.swf to your host.
Run your application and verify it works.
Send me a check for the money you save on bandwidth (Don’t worry Metal, we will split it 60/40).
If you compare the size of the SWF inside the SWC and the SWF created with mxmlc, you should see a very large difference. Since your new SWF is much smaller than your old one, your application will take less time to load across the wire. Fun stuff!