9/5/2010 10:28:28 PM
Title:
Updating code on multiple SWFs using RSLs
I thought this was possible, but I seem to have trouble making it work.
I want to have my code/class library stored in an RSL (as a SWF online) which is then loaded during runtime by the host SWF. I learned about this technique from Colin Moock in his book Essential Actionscript 3.0 (Chapter 31: Distributing a Class Library).
Now, I know that if you share graphics between SWFs via RSLs, you can update the graphic in the RSL and have all SWFs that access that RSL use that updated graphic.
But I want to store code in an online RSL, that is shared by multiple SWFs, and then when the code needs to be updated, I simply recompile the SWF (do I even need to worry about the SWC anymore?) containing the class library and upload and overwrite the existing RSL on the web. Voila! The code is now updated in all SWFs that share that RSL Class Library.
The problem is, I can't get it to work right. CS3 and CS4 aren't updating and CS5 just crashes on export!
The code I'm testing with simply outputs some chosen text to screen.
I want to change the string that's output by changing the code. Nothing fancy now, but it'll obviously be used for far more indepth stuff when (if?) I get this going properly.
Has anybody else tried to do this before? Were you successful? I could really use your help!
Tyson
Points: 680
Posts:0
9/6/2010 4:15:49 AM
Rob , this thing is possible in flex but does not seems to be feasible for flash, the reason is that flex is framework based and does not initialize until the RSL is loaded but in case of flash there is no such dependency so it never waits for RSL to load before initializing the code inside.
9/6/2010 12:24:35 PM
Thanks for your reply, Tyson! It still doesn't make sense to me that, if the classes in the RSL aren't included in the host swf at compile/publishing, and are loaded at runtime, why an update to the code it loads at runtime isn't shown when the host swf runs that new, loaded code.
Just to be clear... class names, packages, method names... they ALL stay the same. It's merely something inside the function that changes... such as using a different string to output.
9/6/2010 6:08:48 PM
Well, I figured out the problem finally and I'm documenting it here in case someone else has a similar problem with it, and for my own records.
[SIZE="4"][B]Using runtime shared libraries (RSL's) to dynamically change code/classes at runtime: things to keep in mind.[/B][/SIZE]
When creating your SWC/SWF:
[LIST=1]
[*]When doing your import of classes, DO NOT try to import an entire folder using ".*" notation! It won't work (as in, import the classes), and even worse, it'll fail silently leaving you to bang your head trying to figure out what's wrong! At least, not for any custom classes such as ones you made. [B]You need to import each class specifically![/B]
[*]When you're finished making your SWC/SWF, remember to remove the .AS files (that were imported into the SWC/SWF) from your source path, otherwise, they'll get bundled into your host SWF, negate the filesize savings and make dynamic updating of the code/RSL/SWF impossible.
[/LIST]
I got my runtime shared library technique originally from Colin Moock's (otherwise excellent) [I]Essential Actionscript 3.0[/I]. But I really, really wished he mentioned those two points in the book!
Also, remember to change your publish settings for Actionscript 3 to make sure your External Library Path points to the corresponding SWC used for compile time checking or you'll get errors.
This was done in CS4. I played around with trying to do it in CS5, but got tired of it crashing all the time. :mad: