Gilles Vandenoostende

Hi, I'm Gilles Vandenoostende - designer, illustrator and digital busybody with a love of language, based in Ghent, Belgium.

“SecurityError: Error #2000: No active security context.”

I encountered a strange bug in Flash player 10 today. A simple flash animation, scripted in AS3, which gave no errors inside the CS3 IDE threw the following error when run inside the browser (which was running flash player 10):

SecurityError: Error #2000: No active security context.

Now, the animation itself is completely static, no external content or links of any kind, so this error threw me off. A quick google search later, and I had tracked the bug down the the following innocuous line of code:

setTimeout(_launchTimer.start, 3000);

“_launchTimer” being a simple Timer object. The workaround, was to wrap the call to the timer’s start() function in an anonymous function, like so:

setTimeout(function():void{_launchTimer.start();}, 3000);

Very strange indeed… It seems like FP10 doesn’t like setTimout calling functions that aren’t in the same scope from where the setTimeout is being called for some reason. I’m blogging about this so that hopefully, other developers tearing their hair out at this strange bug might be helped by this.
Also, happy 2009 everybody!

25 Comments

The same error sometimes happens for loading data using the filereference.load method. the data property of the filereference contains the error message and not a byte array as expected.

In this case, I used your solution and wrapped the load function in a similar way, which is a little bit :

setTimeout( function():void{fileReference.load();}, 1);

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

Posted by Ingo at May 20th, 2009 at 2:57 am.

Oh my god!

Even while not sharing a desk anymore you magically answer my questions!
I ran into the same bug today. I google… And where do I end up?

Magic!

Thanks for the fix, works as like charm.

Posted by Bert at July 20th, 2010 at 10:40 am.

Haha, hadn’t noticed this comment so it was stuck in my moderation queue, but glad it helped :)

Figured it was such an odd and illogical bug that someone somewhere would run into it eventually.

Posted by @gillesv at September 2nd, 2010 at 2:59 am.

I have the same problem – same security error. But using this solution:
setTimeout( function():void{fileReference.load();}, 1); doesn’t resolve my problem. I googled for this problem and found only this solution. Please help.
P.S. I am using flex 4 SDK

Posted by MiMi at December 16th, 2010 at 2:31 pm.

Strange. Have you tried with a larger timeout? Why the timeout at all, if it’s only one millisecond?

Posted by @gillesv at January 17th, 2011 at 1:49 am.

Just a note that you can bogusly get this error if there is a problem with your external media. For example if you specify ‘file.jpg’ in code and your filename is in fact ‘file.JPG’.

The local player seems to work around this case problem while a remote server will have none of that.

Posted by imakeinterfaces at February 8th, 2011 at 7:59 pm.

Thanks for that note ImakeInterfaces, Ive been trying to figure this out for hours. Turns out like you said that the file name on the server didn’t quite match the file name in the xml. It really is the most vague error ever though, id have still been racking my brains if it wasn’t for your post..

Posted by Jamie at February 17th, 2011 at 4:39 am.

[…] ein FlashPlayer-Bug zu sein: “SecurityError: Error #2000: No active security context.” Gilles Vandenoostende : Musing… __________________ greetz Thomas [ Progger, kein Designer ] Ich kann die FLA-Datei nicht […]

Posted by SecurityError: Error #2000: Kein aktiver Sicherheitskontext - Flashforum at March 23rd, 2011 at 3:26 am.

Great post, i had the same Security Error and i fix it adding a IOErrorEvent.IO_ERROR to the Loaders. Hope this help anyone.

Posted by Nicolas at March 25th, 2011 at 12:15 pm.

This error can also crop up when loading external assets (swfs, images etc.) and the url of the asset is in the wrong case.

For example loading a child swf named ‘Child.swf’ by:

var urlRequest:URLRequest = new URLRequest(“child.swf”);

var swfLoader = new Loader();
swfLoader.load(urlRequest);

The code above worked when running it locally but when uploaded it came up with “SecurityError: Error #2000: No active security context.”

Posted by Demo at March 31st, 2011 at 6:50 am.

Thanks a lot Nicolas!! I solved my problem by adding a listener to the IOErrorEvent.IO_ERROR event. No more SecurityError #2000 for me :)

Thanks!

Posted by Vlad at April 7th, 2011 at 6:19 am.

Check your directory to make sure you uploaded your swf before anything else

As was the case with me…

:)

Posted by Michael Benin at April 23rd, 2011 at 2:22 pm.

Can you explain this is plain English please so us normal human beings can fix it also :) thanks

Posted by mary at April 27th, 2011 at 3:14 am.

As far as I can tell, if you know enough Actionscript that you can code something that would generate this error, you should be able to understand the solutions offered both in my original post and in the comments that followed. I don’t think there’s any easier way to describe it than that.

Posted by @gillesv at April 27th, 2011 at 3:24 am.

Hey VLAD can you explain more aboy ou EVENT IO_ERROR ?? i have the same error trying to load a external SWF

Posted by Rodolfo at April 28th, 2011 at 7:23 am.

Check the url you’re trying to load. IOErrorEvent means the location of the file you’re trying to load doesn’t exist.

Posted by @gillesv at April 28th, 2011 at 8:36 am.

I too started to get this error in FP10, when previously all had been OK in FP9
I tracked it down to the connection name parameter in LocalConnection objects. The name must be identical in both sending and receiving objects in terms of case.
So….
SWFOne.send(“inputMessage”, “MessageParser”);
SWFTwo.connect(“InputMessage”);
Will fail.

Posted by Martin at May 15th, 2011 at 4:01 am.

I think my problem has to do with referencing an xml file, but I am using a CMS that references the file via a virtual directory.

So instead of:

_xmlLoader.load(new URLRequest(“http://www.example.com/site/data.xml”));

it has to be:

_xmlLoader.load(new URLRequest(“http://www.example.com/site/data/”));

I’m guessing Flash doesn’t like the later and that is why I am getting the error. Anyone else run into this problem?

Posted by Eamon at May 17th, 2011 at 3:04 pm.

Fuck you flash and you stupid hacks and work arounds!!!!

Posted by Jaded Flash User at May 18th, 2011 at 6:09 pm.

Now now, any technology that’s been around as long as Flash has will have its fair share of bugs and subsequent work-arounds. If you don’t like Flash, there’s plenty of other technologies that are viable alternatives. Try HTML, CSS and Javascript (although if you’re already this outraged at this minor bug, I doubt you’ll have the stomach to handle some of JS’ legendary idiosyncrasies).

Posted by @gillesv at May 19th, 2011 at 1:50 am.

I just got the same error, but nothing of the above solutions worked for me. I tried loading external images from an xml, with was perfectly working a month ago. It still worked locally but as soon as i tried it online I got the Security Error.
Although the problem was solved when I set my directory permissions for the images folder to 777.

Good Luck everyone!

Posted by Tigerkatze at June 3rd, 2011 at 1:27 am.

like imakeinterfaces, said.. most often it is something simple. I was working on a flash player and couldn’t figure out why I kept getting this message after adding another mp3 file to the source directory.. one space between the song “title” on the xml play list and no space on the mp3 file name. (was working on very little sleep).. renamed the file and the error went away.

Posted by Webbie at September 28th, 2011 at 11:18 pm.

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

Posted by mjameei at December 11th, 2011 at 12:26 pm.

Thanks, managed to find that it was an URL misprint in the xml file after changing directories.

Good work.

Posted by Simon at April 2nd, 2012 at 2:03 pm.

Thanks, this helped me too… while in Sandbox my FLA and therefor the SWF was not in the same dir as an MP3 being used for a sound effect. Odd ambiguous error… thanks for the comments and OP for the help.

Posted by Craig at August 17th, 2012 at 10:52 pm.

Back to top