Skip to main content
screeen
Inspiring
February 26, 2012
Answered

Loader:NaN.jpg + SecurityError: Error #2000: No active security context.

  • February 26, 2012
  • 2 replies
  • 1250 views

hi.

Using the code below, i am getting Error #2035, informing me that my jpg is not a number.

Same code with the ioErrorHandler bits comments, outputs SecurityError: Error #2000: No active security context.

Same code without the randomNumber and with the proper path to the jpgs in the string, works fine (loads 16.jpg), as such - var req:URLRequest = new URLRequest("../images/16.jpg");

Any ideas?

import flash.display.*;

import flash.net.URLRequest;

import flash.display.Loader;

import flash.events.*;

import flash.utils.setTimeout;

var req:URLRequest = new URLRequest("../images/"+randomNumber+".jpg");

var loader:Loader = new Loader();

var randomNumber:Number = Math.ceil(Math.random()*16);

function imageLoaded(event:Event):void

{  

    addChild(loader);

}

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);

loader.load(req);

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

function ioErrorHandler(e:IOErrorEvent):void{

    trace(e.text);

}

This topic has been closed for replies.
Correct answer kglad

use:

import flash.display.*;

import flash.net.URLRequest;

import flash.display.Loader;

import flash.events.*;

import flash.utils.setTimeout;

var randomNumber:Number = Math.ceil(Math.random()*16);

var req:URLRequest = new URLRequest("../images/"+randomNumber+".jpg");

var loader:Loader = new Loader();

function imageLoaded(event:Event):void

{  

    addChild(loader);

}

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);

loader.load(req);

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

function ioErrorHandler(e:IOErrorEvent):void{

    trace(e.text);

}

2 replies

screeen
screeenAuthor
Inspiring
February 27, 2012

YEAH!!!!

cant thank you enough. am so thankful that i dont even feel stupid:)!

kglad
Braniac
February 27, 2012

you're welcome.

kglad
kgladCorrect answer
Braniac
February 26, 2012

use:

import flash.display.*;

import flash.net.URLRequest;

import flash.display.Loader;

import flash.events.*;

import flash.utils.setTimeout;

var randomNumber:Number = Math.ceil(Math.random()*16);

var req:URLRequest = new URLRequest("../images/"+randomNumber+".jpg");

var loader:Loader = new Loader();

function imageLoaded(event:Event):void

{  

    addChild(loader);

}

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);

loader.load(req);

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

function ioErrorHandler(e:IOErrorEvent):void{

    trace(e.text);

}