Donate to protect them directly or help international organizations.
AS3 and Runtime Sharing
January 25th, 2008
Runtime Sharing has been quite a puzzle for me for some time now. Here are a few problems that I solved:
Exporting an imported asset
When in AS3 you want to import an asset from a swf, you get it by its linkage name. What if this asset needs to be imported from another swf? Flash only allows you to import OR export an asset for Runtime Sharing. Simple: in Flash, encapsulate the imported asset in a MovieClip, and export the parent clip with a different linkage name.
Load swf with runtime sharing dependencies
If you use the Loader class to load assets into your AS3 app and the source swf has dependencies, the Loader might not fire a COMPLETE event. Although you expect your app to go look for dependencies in the path relative to your source swf, it actually looks for it relative to the app. Since it doesn't find it, your app has unpredictable behavior. Solution: move shared.swf to root, make an alias in root or change the linkage path in myassets.swf (might be tiresome).
Here is an example:
- main.swf
- assets
- myassets.swf
- shared.swf
myapp.swf is an AS3 app that loads myassets.swf
myassets.swf imports assets from shared.swf using the path "./shared.swf"
myapp.swf will look for dependencies in "root/assets.swf", because that is the folder that contains the app.
Solution:
- main.swf
- shared.swf
- assets
- myassets.swf
It took me a long time and a bit of luck to figure it out. Hopefully you will benefit from it.
Previous: Working with types in AS3 Next: FlexNativeMenu Tutorial & Issues