An SWC library complied with Flex 3 SDK, being added to Flex 4 project and conflicts with Flex 4 namespaces. Similarly, legacy Flex 3 SWF file has to be used within Flex 4 application. Latter can be found in large/legacy applications.
Implement legacy code within separate Flex application, compile with Flex 3 SDK and embed into Flex 4 application.
Technology named Marshall Plan can separate contexts the applications are run in. A Flex 3 library or application should be embedded into Flex 4 application in so-called 'sibling context' not to interfere with Flex 4 namespaces and classes. If there's no option to re-compile Flex 3 code with Flex 4 SDK, then simply load Flex 3 application with code like this:
<mx:SWFLoader id="legacy" source="legacy.swf"
loadForCompatibility="true" />
Note last clause - this tell Flex 4 to use Marshall Plan and load SWF into sibling context, not into main context (otherwise it will conflict).
If you decide to move part of business logic into Flex 3 SWF and use within Flex 4 application via Marshall Plan, you cannot just access SWF's data. You'll have to use events and listeners to communicate between the two.
Sending event from Flex 3 SWF:
var e:Event = new Event("FOOEVENT");
this.systemManager.loaderInfo.sharedEvents.dispatchEvent(e);
Listening for event in Flex 4 app:
contentLoader.content.loaderInfo.sharedEvents.addEventListener(
'FOOEVENT' , onFoo );
private function onFoo(evt: Event): void {
// do something
}
Marshall Plan can also be useful if loading SWFs into application from different security contexts (remote vs. local).
+