views:

650

answers:

2

I'm trying to compile an existing Flex3 project with the Flex4 SDK. I'm getting this error:

Warning: This compilation unit did not have a factoryClass specified in Frame metadata to load the configured runtime shared libraries. To compile without runtime shared libraries either set the -static-link-runtime-shared-libraries option to true or remove the -runtime-shared-libraries option.

The resulting file is roughly the same as my old Flex3 compiled .swf file. Playing the resulting .swf file in the Flash Player also gives the following errors:

An Actionscript error ocurred: VerifyError: Error #1014: Class spark.core::SpriteVisualElement could not be found

If I set the compiler attribute static-link-runtime-shared-libraries to true, then the error disappears and all is well. However, the size of the resulting .SWF is a couple of 100K's bigger. And that's not what I want.

I don't fully understand the concept of runtime shared libraries, but it seems that with the option to statically link them set to true, the libraries are included in the .swf. However, I like to exclude them from the .swf and only load the needed library at runtime, as my project seemed to do with Flex3 (I didn't know that by the way).

If I understand correctly, playerglobal.swc should hold all the necessary code for the external libraries that my .swf has to load. Do Flex4 compiled files need more libraries? Should I do something with the factoryClass in the Frame metadata tag?

I think my question boils down to this: How do I compile a Flex4 .swf that is the same size as my previous Flex3 compiled .swf?

+1  A: 

Flex3 did not use rsls by default but you could enable them. Flex4 rsls are enabled by default, see: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7add.html

The concept of runtime shared libraries is: splitting of a part of your application that is (re)used by other apps as well, thereby only requiring the user to download it once. This won't save anything on the first download but will save on later downloads. You could possibly make your own rsl, but it's mostly the ones provided by adobe that are meant to make the difference: Since 'everybody' will use them there will be a bit chance the library you need is already present on the user's system, thereby speeding up the download-time of your app.

playerglobal.swc never contained any flex framework classes, most of them are in flex.swc and framework.swc (a standard flex 3 project also includes rpc.swc and utilities.swc - I didn't check but these probably contain some flex parts as well)

Simon Groenewolt
Thanks, this helps a little to understand it all. But if I enable RSLs in Flex4, how come I still get those VerifyErrors? If I understand you correctly, the RLS should have been loaded before my .swf starts, and there wouldn't be any VerifyErrors.
Monokai
The warning tells you why you get the verify errors: Your don't have a factory class to load the correct rsls - my guess is that there is some command line option to specify the rsls you want to use, that option will take care of generating the right factory class that will load them at runtime.
Simon Groenewolt
Thanks for thinking along. The RSLS are specified in flex-config.xml. I only use the ones from Adobe. If I enable `static-link-runtime-shared-libraries` in app-config.xml, then my app compiles fine. So that probably means the RSLS are correctly referenced. Errors only happen when I'm compiling with `static-link-runtime-shared-libraries` set to false. Which gives the factoryClass error + VerifyError. I still don't understand. I think I've read everything about compiler options, but still haven't found a solution.
Monokai
just a check: is your main class a .as file or a .mxml one?
Simon Groenewolt
It's a pure AS3 project. Only .as files. Looks like I don't need the extra Flex functionality and Flex RSLS, but does that mean I can't compile my project with Flex4? Should I just revert back to 3.5? I also notice that the compiler injects stuff I don't need (UIObject for instance).
Monokai
I think you are right - apparently you somewhere reference a bit of flex-framework code _or_ the compiler actually inserts something. I'd suggest trying to compile with a custom flex-config that doesn't include the flex libraries, or if you find that you cannot work without some flex components: have a look at http://www.bit-101.com/blog/?p=946 and add the preloader yourself.
Simon Groenewolt
A: 

Looks like you might have project migration problems. You might want to read up on the process on:

http://www.adobe.com/devnet/flex/articles/flexbuilder3_to_flashbuilder4.html

It's a really good article with overview of different possibilities for migration, depending on the amount of Flex4 stuff you want to use.

jpop
Thanks for the link. However, I'm not using Flash Builder, but compile from the command line via MXMLC.
Monokai