4

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?

Monokai
  • 1,163
  • 2
  • 10
  • 16
  • It's not clear to me if you just want to compile the flex3 project or that you actually want to include some new/updated flex4 functionality. Also: are you compiling on the command line or using flex builder / fdt? – Simon Groenewolt Jun 20 '10 at 12:11
  • I need to recompile the Flex3 project first, and perhaps later add some Flex4 functionality. But compiling the Flex3 project is my main priority. I'm compiling using mxmlc on the command line. My project consists of multiple .as files. – Monokai Jun 20 '10 at 13:18
  • I assume that "path.to.your.preloader" identifies some class, right? Is there any class Adobe has already written for the common case where the shared libraries are to be found at the same place where the main .swf was found? –  Nov 24 '11 at 13:53

3 Answers3

5

You have to add [Frame(factoryClass="path.to.your.preloader")] to the main class (the one you set in the compiler options).

Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
chriszichrisz
  • 51
  • 1
  • 2
1

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
  • 10,607
  • 1
  • 36
  • 64
  • 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 Jun 20 '10 at 13:27
  • 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 Jun 20 '10 at 21:52
  • 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 Jun 22 '10 at 08:46
  • just a check: is your main class a .as file or a .mxml one? – Simon Groenewolt Jun 23 '10 at 07:52
  • 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 Jun 24 '10 at 08:50
  • 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 Jun 24 '10 at 14:41
1

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
  • 1,094
  • 1
  • 7
  • 19
  • Thanks for the link. However, I'm not using Flash Builder, but compile from the command line via MXMLC. – Monokai Jun 21 '10 at 13:07