tags:

views:

85

answers:

2

I am interested in understanding how to run a Flex-3 SWF inside a Flex-4 SWF.

My Flex-4 host app looks like this:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

    <mx:SWFLoader source="SimpleFlex3App.swf" loadForCompatibility="true"/>

</s:Application> 

And this is the Flex-3 app:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="400">

    <mx:Script>
        <![CDATA[

            private function onClick():void
            {
                labelField.visible = true;
            }   

        ]]>
    </mx:Script>

    <mx:Button label="Click Me" click="onClick();" horizontalCenter="0" verticalCenter="-20"/>
    <mx:Label text="Clicked" visible="false" id="labelField" horizontalCenter="0" verticalCenter="20"/>

</mx:Application>

I get a null object reference where the SWFLoader tries to set up the bridge. I assume it does not get an instance for the IMarshalSystemManager implementation.

IMarshalSystemManager(sm.getImplementation("mx.managers::IMarshalSystemManager")).addChildBridge(_swfBridge, this);

By using the SWFLoader and setting loadForCompatibility to true I was following the adobe documentation:

I must be missing out on something very simple as both, my host and hosted apps, basically don't do anything special.

Further, is it possible to do the opposite and run a Flex-4 based SWF inside a Flex-3 one? In my opinion the adobe doc does not clearly say yes or no.

Thanks.

A: 

It is possible to do as I built an application that can load AS2 swfs into a Flex 3 SWF.

You may need to set the trustContent property to false. This will mean you swfs are in separate security domains, and communication between the two will need to happen over a shared event bridge, local connection or custom sockets.

Have a look here for more info on this http://www.pixelbox.net/2009/02/11/sub-application-communication-in-air/

robmcm
robmcm, thanks for your thoughts but that didn't help. I simplified my problem meanwhile to the most simple case I could think of and updated my original post accordingly.
Stefan
Glad you got it sorted!
robmcm
+1  A: 

Flex harUI provided the correct answer here at the adobe forum.

Thanks!

Stefan