Copy link to clipboard
Copied
When I try to load an external image from a folder called assets, this is the error I get:
SecurityError: Error #2000: No active security context.
My code is:
Copy link to clipboard
Copied
looks like a path issue, try installing an event handler for IOErrorEvent.IO_ERROR on the loader.contentLoaderInfo for more details. You can check the example at the end of this page: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/LoaderInfo.html. for reference.
-Dharmendra
Copy link to clipboard
Copied
I didn't understand the soultion, can you show a code that I can use?
I'm pretty much a beginner
Copy link to clipboard
Copied
You can try the following in your case. The function ioErrorHandler should give you more details if there is a path issue.
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.*;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(new URLRequest("assets/boats.jpg"));
addChild(loader);
function ioErrorHandler(event:IOErrorEvent):void {
trace("Error: " + event);
}
Copy link to clipboard
Copied
I got this:
Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2035: URL Not Found. URL: file:///C|/Users/PCName/Desktop/assets/boats.jpg"]
Copy link to clipboard
Copied
Well that's the problem.
URL Not Found. URL: file:///C|/Users/PCName/Desktop/assets/boats.jpg"
Just check the path, and change your code accordingly, that should work.
-Dharmendra
Copy link to clipboard
Copied
I put the full path and it still didn't work:
"C:\Users\PCName\Desktop\assets\boats.jpg"
Find more inspiration, events, and resources on the new Adobe Community
Explore Now