开发者

Warning when migratring from Flex 3 to Flex 4

开发者 https://www.devze.com 2023-01-09 23:30 出处:网络
I received this warning when I migrated my application from flex 3 to flex 4: components:MyApp is a module or application that is directly referenced. This will cause components:MyApp and all of its

I received this warning when I migrated my application from flex 3 to flex 4:

components:MyApp is a module or application that is directly referenced. This will cause components:MyApp and all of its dependencies to be linked in with modules:searchModule. Using an interface is the recommended practice to avoid this. Unknown Flex Problem

MyApp is a class which extends the Application component and in the module named "searchModule" there's this line:

var parentApp:myApp = parentApplication as MyApp;

I then use the variable myApp to call methods defined in the MyApp class from within this module.

This warning is reported 10 times because I am doing the same in other modules.

I want to fix it but I don't understand the part "this will cause its dependencies to be l开发者_如何学Cinked in with modules" and how would I make an interface to avoid this? And why there wasn't a warning about it in flex 3?

Thanks in advance


I'm guessing a bit, but...

The Flex Framework is one of those special Adobe-only libraries that can be cached by the Flex player. As such, with certain compile settings, the SWF from the compiler does not contain the Flex library. In lex 4, the framework is not compiled into your application SWf, resulting in significantly smaller application file size.

If you extend the Application class, which it sounds like you done, the compiler cannot count on your new "Application" being in the cached Flex Framework and therefore must compile your new class, and therefore the Application tag into your SWF. This is going to daisy chain significantly; as the Application tag does a lot of Flex Framework setup stuff.

I assume that is what the warning means in terms of dependencies.

Did you really extend Application with additional functionality? Or is "MyApp.mxml" just the name of the your main application file?

You might try this:

var parentApp:Application = parentApplication as Application;

I believe there is a FlexGlobals class introduced in Flex 4, which can also give you access to the top level Application.

In terms of using an interface. Interfaces are designed to help remove specific dependencies. You can create an interface for your new functionality of the new Application class and reference that instead.

var parentApp:myApp = parentApplication as IMyApp

Based on my interpertation of the messages you're seeing that may address the issue.


I had this error when I had Application MXML insted of Component MXML, for example. Changed Application to Group, in referenced Component, and warning was no more.

Reason for error was, because I worked on component in separate project as application, and later copied it to main project, but I didn't change it to component.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号