Just a quick issue I ran into today whilst trying to make use of runtime font loading inside Flash Builder. Where as before in Flex 3 it was a simple case of creating a class to construct a swf that would then be loaded in the main application. Today I ran into an Error #1014 - Class mx.core::FontAsset could not be found, when running the main application.
The fix as it seems is to add this to the compiler arguments of your font library swf.
-static-link-runtime-shared-libraries=true
Now if like me you use Ant Builder to compile your projects - simply add to your mxmlc tag within your ant script as shown here
file="${SOURCE_DIR}/FontLibrary.as"
output="${OUTPUT_DIR}/fontLibrary.swf"
locale="${LOCALE}"
static-rsls="false"
static-link-runtime-shared-libraries="true"
accessible="true"
Update: Adobe mention a fix to the noticeable file size increase. It appears that the increase is due to it including all classes that our "classes inherit from plus other framework dependencies" so we need to amend this script a little to something more like
mxmlc -runtime-shared-library-path=c:/p4/flex/flex/sdk/frameworks/libs/framework.swc, framework_3.0.183453.swz,,framework_3.0.183453.swf rsls/SimpleApp.mxml
For a more detail explanation check out Adobe's comments
Goga
November 4, 2010 at 9:24 am
Thank a lot ! Very helpful for me!
emmanuel
January 19, 2011 at 12:32 am
at last!! thank you
Miguel Martín
March 8, 2011 at 9:48 am
This post has been so helpful. Thanks.
By the way, if you compile using that compiler arg, the resultant swf weights almost 200ks while if you compile without it, it will weight near 160ks less (in my test 30ks aprox).
Another thing you can try, is loading your font library (swf) setting a trustable LoaderContext:
loader.loaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, SecurityDomain.currentDomain);
This should work too and will keep your swf files lighter.
emile
March 25, 2011 at 5:50 am
http://livedocs.adobe.com/flex/3/html/help.html?content=rsl_09.html
Towards the end it explains that the increase in file size is due to the static-link-runtime-shared-libraries=”true” embeding various aspects of the framework.swc into your swf file. It offers an alternative. Though i haven’t tested this yet.
Thanks for the tip though.
admin
March 29, 2011 at 4:10 pm
Thanks for the heads up Emile – this is one of the most used resources on my site so this tip will help a lot of people!
FlashJonas
May 20, 2011 at 1:07 am
Yay! “-static-link-runtime-shared-libraries=true” did it for me! 🙂
Cheers
Grzegorz
April 3, 2012 at 6:00 am
Thanks a lot! did it for me