Home > Uncategorized > SecurityError: Error #2000: No active security context.

SecurityError: Error #2000: No active security context.

Always interesting to throw an error that has only 4 obscure results in google.
Using setTimeout with navigateToURL:

var urlRequest:URLRequest = new URLRequest("http://google.com");
setTimeout(navigateToURL, 1000, urlRequest, "_blank");

Generates:
SecurityError: Error #2000: No active security context.
at global/flash.net::navigateToURL()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at <anonymous>()
at SetIntervalTimer/onTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

A work around is to wrap the call in an anonymous function:
setTimeout(function():void { navigateToURL(urlRequest, “_blank”); }, 1000);

Categories: Uncategorized Tags: ,
  1. pallzoltan
    November 18th, 2008 at 08:03 | #1

    well, i get this error when trying to access the data property of a filereference… :) weird stuff

  2. Andy
    January 2nd, 2009 at 23:47 | #2

    I just joined this tragic club… What the hell is this error about? I get it when using LocalConnection within FlexBuilder 3 (in Eclipse).

  3. Lisa
    February 11th, 2009 at 11:32 | #3

    I’m with you pallzoltan. When trying to access the data property of a filereference.

  4. Ivan
    April 15th, 2009 at 10:21 | #4

    @pallzoltan

    The filereference.data error can also be fixed with the setTimeout or timer function.

  5. Ingo
    May 20th, 2009 at 01:51 | #5

    For filereference.data to work as expected, the load() function has to be wrapped:
    setTimeout( function():void{fileReference.load();}, 1);

    Maybe there are some more elegant ways to achieve this, however it works for me.

  6. June 17th, 2009 at 10:30 | #6

    FYI, I just wasted a few hours because the FlexBuilder debugger displays this message until the getter is actually accessed in the code. Apparently, the debugger runs in a separate security context. As it turns out, this “error” wasn’t even a problem. So for a bit of advice, try doing a trace(“” + loader.content) before you jump to conclusions.

  7. February 22nd, 2010 at 00:03 | #7

    Can anyone explain what this error even means? I’m getting it trying to use setTiemout to delay the intitial start a Timer:
    setTimeout(myTimer.start, 1000)

  8. MiMi
    December 17th, 2010 at 07:42 | #8

    I’ve wrapped filereference.load to setTimeout as Ingo suggested but filereference.data still throws the same error. I cannot find any other solution. I am not sure why I am getting this error when I am trying to upload image file and how I can resolve. Any one… Please help…

  9. February 4th, 2011 at 15:42 | #9

    It appears that this error can appear if a function call triggered by LocalConnection throws an error. Unintuitive case, for sure. Thankfully, it became obvious when I ran the debugger.

  10. February 25th, 2011 at 20:07 | #10

    i get this when tring to acess games on facebook

  11. tom
    March 17th, 2011 at 06:26 | #11

    Had this problem when rendering HTML in a Flex component that was using the tag

  12. tom
    March 17th, 2011 at 06:27 | #12

    ^^^ .. that was using the “img” tag

  13. Frank
    May 6th, 2011 at 17:13 | #13

    i had this error when loading in a xml file…so weird, never happened before today.

  14. Frank
    May 6th, 2011 at 17:17 | #14

    ok, just solved the problem,
    my code before was
    var xmURL:URLRequest=new URLRequest(“C:/Users/frankshan/Downloads”);
    it’s suppose to be
    var xmURL:URLRequest=new URLRequest(“C:/Users/frankshan/Downloads/timeline.xml”);

    so stupid…. :(

  15. juanargento
    May 24th, 2011 at 09:45 | #15

    The same issue happened to me when i was trying to call the save() method of the FileReference class. The workaround that I found to solve this issue is add a listener for the IOErrorEvent and just catch the exception that is trown:

    Here my code snipped:

    var byteArray:ByteArray = myPDF.save(Method.LOCAL);
    var fileRef:FileReference = new FileReference();
    fileRef.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
    fileRef.save(byteArray, “MyReport.pdf”);

    private function onIOError(event:Event):void {
    //do nothing here
    }

    Hope this helps somebody else.

  16. ministe2003
    June 1st, 2011 at 02:56 | #16

    Just wanted to add my experience here, I was looping through a bunch of URLs and downloading images from the urls with a Loader, I was getting this error and it turned out some of the URLs had changed and no longer contained the data I was trying to download.

    Simple tip, as juanargento says, catch the IOErrorEvent and add a breakpoint on it – when you hit it, look through the data to see if you’re trying to download a null value!

  17. Diane
    June 12th, 2011 at 08:51 | #17

    I’m getting the same error message when playing all pogo games. HELP

  18. Kate
    July 21st, 2011 at 19:32 | #18

    I am simply trying to load a local jpg and I get this error!

  19. benjoya
    August 16th, 2011 at 12:59 | #19

    yeah, when there’s a problem in the URL, you get this error. trace out the url, make sure your assets are in the right place.

  20. BrainDad
    November 24th, 2011 at 07:26 | #20

    Hey Frank,
    you must be the brain here..

  21. mjameei
    December 11th, 2011 at 03:25 | #21

    if you receive this error when trying to establish a local connection, don’t forget to add this to your code :
    localconnectioninstance.client=this;
    this is for redirecting requests to a different object other than the receiving local connection instance

  1. June 13th, 2009 at 09:28 | #1