ActionScript Security Error 2060: Security sandbox violation

ActionScript Security Error 2060: Security sandbox violation: ExternalInterface caller
file:///C:/Curtism/ExternalInterface_GA.swf
cannot access
file:///C:/Curtism/ExternalInterface_GA.html

Description:This error pops up when you are testing or deploying a web page that uses ExternalInterface to call a Javasacript function on the containing HTML page.  You may see this error when using Flooglytics (Flash and Google Analytics) or whenAjax is used in conjunction with Flash.  It basically means that what you are doing is not allowed with the way you have embedded your swf.  It is a really simple solution to fix this ActionScript Security Error

Flex / Flash Security Error #2060 Fix:
In the HTML make sure that the parameter ‘allowscriptaccess’ is set to ‘always’ rather than ‘sameDomain’ or ‘never’ in all cases.  Do a search in your HTML for allscriptaccess and change all references.  Usually there is two places to cahnge this.

Bad HTML Code using swfObject 2.0:

so.addParam('allowscriptaccess', 'sameDomain');

Good HTML Code using swfObject 2.0:

so.addParam('allowscriptaccess', 'always');

————————————————-

Bad HTML Code using AC_FL_RunContent:

‘allowScriptAccess’,‘sameDomain’,

Good HTML Code using AC_FL_RunContent:

‘allowScriptAccess’,‘always’,

————————————————-

Bad HTML Code using embed tag:

allowscriptaccess="sameDomain"

Good HTML Code using embed tag:

allowscriptaccess="always"

————————————————-

Bad HTML Object tag:

<param name=”allowScriptAccess” value=“sameDomain” />

Good HTML Object tag:

<param name=”allowScriptAccess” value=“always” />

————————————————-

This should help you resolve ActionScript Securtiy Error #2060

Thanks and as always Happy Flashing

Curtis J. Morley

14 thoughts on “ActionScript Security Error 2060: Security sandbox violation

  1. Didn’t work for me. Changed all instances of allowScriptAccess to “always”. Still get #2060 error for trying the following code:

    var loc:String = ExternalInterface.call(“window.location.href.toString”);
    navigateToURL(new URLRequest(loc), “_self”)

  2. Hi

    I’m facing similar problem, in one workspace there a lot of files all files are working fine but one file is not working whenever i run release the build its show’s the error. so please can u help how to resolve this problem..

  3. Hello,

    What happens when the pesky SecurityError: Error #2060 comes from gmail and/or yahoo mail?

    here’s teh full script error print out …

    An action script error has occurred

    SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller http://l.yimg.com/a/i/us/pim/dclient/cg211_6/img/md5/ec5ad426f0f029dabc87ea9d422cb6b7_1.swf cannot access http://aa.mg4.mail.yahoo.com/dc/launch?.gx=0&.rand=1pcnkgb4ju2ah.
    at flash.external::ExternalInterface$/_initJS()
    at flash.external::ExternalInterface$/call()
    at com.yahoo.websdk.app::YMsgrJsCore()
    at com.yahoo.websdk.app::YMsgrJs()
    at websdk2()

    Obviously I cannot change their HTML, yet this script error is causing my browser to crash each time – really annoying!

    Any thoughts? (thanks for looking into this)

    Sam

  4. Thanks for reminding me! 🙂

    @ Joe: that wouldn’t be possible, otherwise what would be the point of this security measure…

  5. Thanks, but what if you CANNOT change the embedding url, and have to somehow solve this through AS?

    Joe

  6. Hi,

    I had the allowscriptaccess set to “always” and was still getting the error. When I looked at my html carefully, I realized that the mixed capitalization of my ‘allowscriptaccess’ in the tag was causing IE to ignore it. I didn’t realize that the capitalization could/would be any different than in the and its tag which is mixed case ‘allowScriptAccess’. When I changed it to all lower case for the tag, the Security error disappeared.

    Thanks.

  7. Okay, friends, i found answers here:
    http://www.judahfrangipane.com/blog/?p=215

    my summary here:

    Don’t use workspaces/project paths with spaces in them!!
    Don’t use the default flex workspace in “My Documents” <- there is a space!

    I figured out, what I had done just a few minutes ago:
    I had deleted my local project to get a fresh copy from the SVN repository, and I didnt think of specifying the workspace, so my project got set up in the default location containing spaces in the path.
    (file:///C:/Dokumente und Einstellungen/jovica/My Documents/Flex Builder 3)

    If you are using a german Windows version, it’s even worse, because Flex Builder pumps everything into “My Documents” which is a hardcoded string and doesnt represent the “My Documents” folder at all – in german it is “Eigene Dateien” 🙂

  8. This didnt work for me yet, too.
    I definitely changed all occurances of “allwoscriptaccess”.
    But it seems, there can be more causes for this particular scenario, than just the “allowscriptaccess” issue.

    I did not have this error all the time i am working on my Flex Project, just after some recent changes, the error pops out, even with “allowscriptaccess” set to “always”. Hm hm. 🙂

  9. Hi Curtis,
    Thank you very much for this suggestion. I am facing similar problem, which is solved now by applying these steps.

  10. That didn’t work for me on linux. I changed every single instance of “allowScriptAccess” from “sameDomain” to “always” but I still get the same error message. Why else do you think that error is showing?

  11. Pingback: Michael’s Blog » Blog Archive » Flex/Ajax Bridge “Gotchas”

  12. Pingback: Yet another blog… » Blog Archive » jQuery + SWFObject + Flash ExternalInterface #2060 Error

Comments are closed.