Skip to main content
Jul 1, 2009 9:07 AM UTC
Answered

Error with SwfLoader and new application domain

Hi

I have a test with a SWFLoader loading an application in a different application domain.

Test with SWFLoader is ok when you load the application in the same application domain but when I want a new Application Domain, I have an error message with a flahplayer debug version when I use the unload method.

Is this a bug ?

This topic is closed to new replies. Start a new post to keep the conversation going.
mlabriolaCorrect answer
Participating Frequently
Jul 1, 2009 4:05 PM UTC

ok I can't do it, so I copy it here

    public class TestSWFLoader {
        protected var swfloader:SWFLoader;
        
        [Before(async,ui)]
        public function setUp():void {
            swfloader = new SWFLoader();
            Async.proceedOnEvent( this, swfloader, FlexEvent.CREATION_COMPLETE, 100 );
            UIImpersonator.addChild( swfloader );
        }
        
        [After(async,ui)]
        public function tearDown():void {
            swfloader.unloadAndStop();
            UIImpersonator.removeChild( swfloader );            
            swfloader = null;

        }

        [Test(async,ui)]
        public function testLoad() : void {

            swfloader.addEventListener(Event.COMPLETE, Async.asyncHandler( this, onLoadComplete, 500 ), false, 0, true );
             var loaderctx :    LoaderContext = new LoaderContext();
            loaderctx.applicationDomain = new ApplicationDomain();
            //loaderctx.applicationDomain = ApplicationDomain.currentDomain;
            swfloader.loaderContext = loaderctx;
            swfloader.load('resources/Example.swf');
        }
        
        protected function onLoadComplete( event:Event, passThroughData:Object )
        {
            Assert.assertEquals(swfloader.source, 'resources/Example.swf');
        }
    }


Okay, I can replicate this.

Having seen it, I can also now replicate it out of the FlexUnit framework though. Seems like this the specific issue with the FU framework is when we add it to the UIImpersonator container, the bridgeToFocus manager is never properly created internally.

I can create the same circumstance in a regular application too if I follow a similar pattern. Willing to look into this more but might need to loop in some others so I don't think it will be a quick fix.

When you have time, please file this as a bug in the FlexUnit jira. Adobe is off this week, so it will be at least next week before I can get an opinion on some of my proposed fixes.

Mike

11 replies

Participating Frequently
Jul 1, 2009 12:54 PM UTC

What version of FlexUnit are you using and, perhaps more importantly, what are you trying to accomplish?

At first glance it sounds like you are retying to run code from a different application domain, but could you clarify before I make any possibly incorrect assertions.

Translate
Jul 1, 2009 1:30 PM UTC

I use FlexUnit 4 and FlexBuilder 3

I want to test the behaviour of a custom class which extends SWFLoader,

including when it loads (and unloads) an application in a new

application domain, but I have this error message so I tried some very

simple tests on SWFLoader.

In my test I just load a swf file in a new application domain and unload

it when it's completed. On the "unloadAndStop" method I have this error

message :

TypeError: Error #1009:

at

mx.managers::SystemManager/removeChildBridge()

at

mx.controls::SWFLoader/contentLoaderInfo_unloadEventHandler()

at flash.display::Loader/_unload()

at flash.display::Loader/unloadAndStop()

at

mx.controls::SWFLoader/load()

at

mx.controls::SWFLoader/commitProperties()

at

mx.core::UIComponent/validateProperties()

at

mx.managers::LayoutManager/validateProperties()

at

mx.managers::LayoutManager/doPhasedInstantiation()

at Function/http://adobe.com/AS3/2006/builtin::apply()

at

mx.core::UIComponent/callLaterDispatcher2()

at

mx.core::UIComponent/callLaterDispatcher()

Translate
Participating Frequently
Jul 1, 2009 3:22 PM UTC

This seems weird that it would have anything to do with FlexUnit.

Can you send me a test case I can use to reproduce?

Translate