mercredi 26 mai 2010

Detecting allowScriptAccess and allowNetworking parameters

Flash parameters allowScriptAccess and allowNetworking values are not accessible within the application. Thus the only way to determine their value is to test them.

Detecting allowNetworking thanks to the flash SecurityError:
private function isNetworkingAllowed():Boolean {
   var isAllowed:Boolean = true;
   try {
      navigateToURL(new URLRequest());
      isAllowed = true;
   }catch(se:SecurityError) {
      isAllowed = false;
   }catch(e:Error) {
      isAllowed = true;
   }
   return isAllowed;
}

Detecting allowScriptAccess thanks to a javascript call:
private function isJavascriptInterfaceAvailable():Boolean {
   var isAvailable:Boolean = false;
   try {
      isAvailable = ExternalInterface.call("function () { return (window.document != null); }");
   }catch(error:Error) {
      isAvailable = false;
   }
   return isAvailable;
}

Voila, c'est la magie du cinéma !

1 commentaire:

  1. Pierre-Antoine26 mai 2010 à 03:20

    Début de l'article en anglais, fin en français. Classe.

    RépondreSupprimer