Исключение SecurityError генерируется при возникновении какого-либо нарушения безопасности.
Примеры ошибок безопасности:
An unauthorized property access or method call is made across a security sandbox boundary.
An attempt was made to access a URL not permitted by the security sandbox.
A socket connection was attempted to an unauthorized port number, e.g. a port above 65535.
An attempt was made to access the user’s camera or microphone, and the request to access the device was denied by the user.
Допустим, мы должны загрузить SWF из любого внешнего URL:
// URL of the external movie content
var myRequest:URLRequest=new URLRequest("glow2.swf");
// Create a new Loader to load the swf files
var myLoader:Loader=new Loader();
// 1st level IO_ERROR input and output error checking
// Listen error events for the loading process
myLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
function ioError(event:ErrorEvent):void
{
// Display error message to user in case of loading error.
output_txt.text = "Sorry that there is an IO error during the loading of an
external movie. The error is:" + "\n" + event;
}
function checkComplete(evt:MouseEvent)
{
// 2nd level SecurityError error checking
// Use the try-catch block
try
{
// Load the external movie into the Loader
myLoader.load(myRequest);
}
catch (error:SecurityError)
{
// catch the error here if any
// Display error message to user in case of loading error.
output_txt.text = "Sorry that there is a Security error during the
loading of an external movie. The error is:" + "\n" +
error;
}
}
movie1_btn.addEventListener(MouseEvent.CLICK, checkComplete);
// Listen when the loading of movie (glow.swf) is completed
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadMovie1);
function loadMovie1(myEvent:Event):void
{
// Display the Loader on the MainTimeline when the loading is completed
addChild(myLoader);
// Set display location of the Loader
myLoader.x = 200;
myLoader.y = 80;
}
Надеюсь, это сработает для вас.