SWF SecurityError: Error #2000: No active security context

33,036

Solution 1

Did your images extensions change, possibly from like .jpg to .JPG or something?

Typically this is called if there is a problem with your external media. Here's a workaround for it, but I typically try and solve versus make it go away.

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

Hope this helps.

Solution 2

I've run into this problem when working with loading images where the path is located in an external XML file. So... I load the XML get the path from it but then the problem I had was I was loading 30+ images and the error was popping up only 6 times so.. I had no idea which file locations where the bad ones.

If you want flash to out put more info than just :

SecurityError: Error #2000: No active security context.

Add this event listener to your Loader:

loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

and finally this function:

protected function ioErrorHandler(e:IOErrorEvent):void{
    trace(e.text);
}

With this in place your Security Error will convert to a URL Not Found Error with the file location you supplied. With this information in hand it should be easier for you to debug the problem.

Error #2035: URL Not Found. URL: file:////Volumes/Macintosh%20HD/Users/cleanshooter/Documents/Website%20/here/there/everywhere/30805/filename.jpg

Solution 3

I faced this issue before,the final conclusion was related to incorrect image path or name

Solution 4

I ran across this issue and used the above setTimeout example but for a slightly different purpose. I was calling a php script that hit Twitter and got the same security issue in Flash debug player. I just wanted to add my example which builds on the above to show how you can use this "workaround" for URLLoader as well as fileReference.

var myXMLLoader:URLLoader = new URLLoader(); 

var urlStr:String = "http://www.yourdomain.com/php/twitter.php"; 
var myVariables:URLVariables = new URLVariables();
myVariables.twitterID = "yourtwitterID";

var myURLRequest:URLRequest = new URLRequest(urlStr)
myURLRequest.data = myVariables;

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

myXMLLoader.addEventListener(Event.COMPLETE, onXMLLoadHandler);

Solution 5

In response to headwinds:


In AS3 you need to import flash.utils.setTimeout. The syntax for setTimeout is setTimeout(A, B, ...rest);

Where B is the function to get called afterwards, A is the delay in ms (e.g. 1000 for a second) and C is any number of parameters you need to provide for the function, separated by a comma.

E.g.

import flash.utils.setTimeout;
// package, etc
//main function
setTimeout(respond, 500, true, false);
private function respond(A : Boolean, B : Boolean) : void {
   var result : Boolean = A == B;
   trace(result);
}
Share:
33,036

Related videos on Youtube

shannoga
Author by

shannoga

Lokking for a new challenge Lots of ideas. No time for all of them.

Updated on July 05, 2022

Comments

  • shannoga
    shannoga almost 2 years

    Hi I have a flash image gallery that worked just fine, until few days a go it stopped loading the images. the debugger throws this error :

    SecurityError: Error #2000: No active security context.
    

    can someone explain what can be the cause?

Related