Hi,
Two days ago I wrote (email 16.Sep "[Flashcoders] allowDomain with wildcard
in the middle swf") about using System.security.allowDomain(*) inside
a file loaded into a "base" swf. The loaded swf, the one with wildcard
would serve as a container for further external files, potentially
incoming from any domain name but at the same time would block access
to "base" swf objects.
The purpose of using LocalConnection described by Kurt is
communication between virtual machines. But it seems still a more
secure way to proxy external domain swfs than using a "shim" file with
a wildcard (*), constantly allowing all incoming files.
Would you use LocalConnection instead of System.security.allowDomain(*)
if the issue would not be connecting between AV1 and AV2 ?
LocalConnection requires a more complex API for accessing internal
object properties than a simple System allowance, but maybe
LocalConnection is more secure at the same time... What is your
opinion ?
Thanks,
Greg
Wednesday, September 16, 2009 (8:54:30 PM):
> Hi All,
>
> Not a question here, but I wanted to share something that was fairly obscure
> in the help docs.
>
> If you are using LocalConnection to talk to an as2 swf from an as3 swf you
> have to do some things differently than you might expect.
>
> Knowing this can really help in trying to completely unload a loaded as2
> swf. For instance, you could change the test function to help you the
> loaded as2 swf unload itself. If you don't successfully do this, things get
> messy quick (memory leak, sound won't stop etc..).
>
> Basic sample code below (hopefully this can help someone in the future).
>
> Kurt
>
> __
>
> Sending swf code (AS3)
>
> var AVM_lc:LocalConnection = new LocalConnection();
>
> // loader loads AVM1 movie
> var loader:Loader = new Loader();
> loader.load(new URLRequest("http://www.yourdomain.com/ as2_receiving.swf"));
> addChild(loader);
>
> loader.addEventListener(MouseEvent.CLICK, testfunction); //just to initiate
> test..
>
> function testfunction(event:MouseEvent):void
> {
> AVM_lc.send("_AVM2toAVM1", "receivingfunction"); //IT IS CRUCIAL to add
> the underscore!! (for more info read about superdomains).
> }
>
> AVM_lc.addEventListener(StatusEvent.STATUS,onConnStatus)
> function onConnStatus(event:StatusEvent):void
> {
> switch (event.level)
> {
>case "status":
> trace("LocalConnection.send() succeeded");
> break;
> case "error":
> trace("LocalConnection.send() failed", event)
> break;
> }
> }
>
>
>
>
>
> Receiving swf (AS2):
>
> var AVM_lc:LocalConnection = new LocalConnection();
> AVM_lc.client = this;
> AVM_lc.allowDomain = function ( domain )
> {
> trace("allow domain called!!") //You can specify that only
> specific domains are allowed. In this case I'm allowing ALL domains.
> //Note; in AS3 code you could just say
> AVM_lc.allowDomain(*);
> return true;
> }
>
> // stopAnimation event handler
> AVM_lc. receivingfunction = function()
> {
> trace("success");
> }
>
> AVM_lc.connect("_AVM2toAVM1"); //Again - the underscore is crucial.
>
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders