Tuesday, March 15, 2011

Flash Error #2048 : Security sandbox violation: %1 cannot load data from %2.

Many Flash AS3 developer have encountered this problem and wondering what the...

The problem is simple.  Your swf in domain A is trying to access a swf from domain B, and it does not like it...



 I have a few solutions to this problem.

1) add a cross domain xml on to the root directory of your domain.  You can see example here.
2) load the swf using byte array.  You can see the example here.
3) add "Security.allowDomain(...domains)" to the swf you are trying to access.

Here is a code to achieve solution #3.

public class IHateDomainIssues extends Issues {
  pubic function IHateDomainIssues():void {
  // allow all domain
    Security.allowDomain("*"); 

  // TODO: your loading swf code
  }
}

There you have it.  Feel free to ask if you have questions.


Related Links:
cross domain
loading-files-using-urlstream
Adobe ActionScript Language Reference

No comments:

Post a Comment