Specifications

51ADOBE FLEX 3
Building and Deploying Adobe Flex 3 Applications
Handling errors
The SecurityError exception is thrown when some type of security violation takes place. Security errors include:
An unauthorized property access or method call was 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, for example, a port below 1024, without
a policy file present.
An attempt was made to access the user’s camera or microphone, and the request to access the device was
denied by the user.
Flash Player dispatches SecurityErrorEvent objects to report the occurrence of a security error. Security error
events are the final events dispatched for any target object. This means that any other events, including generic
error events, are not dispatched for a target object that experiences a security error.
Your event listener can access the SecurityErrorEvent objects
text property to determine what operation was
attempted and any URLs that were involved, as the following example shows:
<?xml version="1.0"?>
<!-- security/SecurityErrorExample.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()">
<mx:Script><![CDATA[
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.SecurityErrorEvent;
import mx.controls.Alert;
private var loader:URLLoader = new URLLoader();
private function initApp():void {
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
securityErrorHandler);
}
private function triggerSecurityError():void {
// This URL is purposefully broken so that it will trigger a
// security error.
var request:URLRequest = new URLRequest("http://www.[yourDomain].com");
// Triggers a security error.
loader.load(request);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
Alert.show("A security error occurred! Check trace logs for details.");
trace("securityErrorHandler: " + event.text);