简体   繁体   中英

Adobe Air loading external swf with allowDomain('*') inside

What i have

Large amount of swfs without it's sources (so i couldn't modify its)

What i need

To load and play this swfs with my AIR app.

The problem

The problem is that this swfs seems having

Security.allowDomain('*')

in their source, so they would throw

SecurityError: Error #3207: Application-sandbox content cannot access this feature.

after i load it. I know that Air doesn't need to use this line, but instead of ignoring or warning on it my full app would stop to executing after loading one of this swfs. If only i could try/catch this string, but as i said i don't have an source of that swfs, so the only thing i could do is to modify my AIR app.

What i tried

What i already tried is to catch all errors inside loader by doning

loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loaderIOErrorHandler);

private function loaderIOErrorHandler(e:IOErrorEvent):void {
    e.preventDefault();
}

but it seems it isn't catch errors inside loader at all

Update

I couldn't share one of this swfs, but here is simulation i made that reproduce problem https://www.dropbox.com/s/0spbdzijfpboi47/problematicSwf.swf?dl=0

Here it's init code

private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);

            Security.allowDomain('*');

            tf = new TextField();

            tf.text = 'Me loaded!';

            addChild(tf);
        }

As you could see it is crashing on allowDomain inside loaded swf. And here is how i load it

var ctx:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
loader.load(new URLRequest(path), ctx);

This is a typical security restriction but it's a very strict one and it's purpose is to make sure the served swf will never be used outside of what it was made for in the first place.

So the short answer to your problem is this: externally loaded swf that are sandboxed with "Security.allowDomain('*');" will not allow a sandboxed AIR app to interact with them in anyway. Instead those swf will be able to interact with the parent AIR app under restrictions via a sandbox bridge.

If truly you cannot modify those swf then you will never be able to add them to a display list in a AIR app or call any of their methods. A sandbox bridge will also be of no use to you.

It's not the answer you want to hear I bet but it's the only one you'll get.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM