R – Is it possible to access static fields declared in a host application by movies loaded dynamically using SWFLoader

actionscript-3apache-flexflashflex3

Is it possible to access declared static fields in a host by a dynamically loaded movie (provided the loaded movie is from a fully trusted domain).

My main concern is to make sure we don't expose data to loaded swf's, but want to still listen to events (via hosted apps callback functions) fired by the loaded swf.


UPDATE

SWFLoader (for flex) and Loader (flash) do vary. SWFLoader wraps Loader, but until Flex API 3.2 (or 3.3?) it seems you can't get direct access to the loaders contentLoaderInfo, which is used as the link to the loaded swf's loaderInfo without having to access first the content property of the host swfloader. In Flex 3.3, they introduce a proprety on SWFLoader.swfBridge that (looking at the source code) exposes the contentLoaderInfo.sharedEvents object of the nested Loader.

But there still seems to be an issue : swfBridge (on the event.COMPLETE) seems to be null?

So how do we get host SWFLoader's contentLoaderInfo.sharedEvents object ?

Best Answer

If you're application A.swf loads a file B.swf from a different domain, and on B.swf's domain there is a crossdomain policy file allowing A.swf to access B.swf's content, yes you can access pretty much all there is inside the B.swf including static fields. You read those using the TextSnapshot class.

If you want A.swf to load B.swf from a different domain, but don't want A.swf to have access to B.swf's content, simply don't allow it to, as for events, I remember there was something called SharedEvents. I was lucky enough not to need this yet, but I remember reading about this in Essential Actionscript 3.0. There was a whole boring chapter about Security. Sorry I can't provide a more concrete example as I'm not responding from my personal experience.

Goodluck!

Related Topic