tags:

views:

424

answers:

3

I am looking to read the value of the allowScriptAccess tag so that if it is set to "never", or if it isn't set that I won't attempt to make an ExternalInterface call. Using the flex framework I can use Application.application. Is there an equivalent for Flash?

A: 

Such information along with any query string parameter can be accessed via the flashVars property. You can access the flashVars properties. Read this for a detailed discussion. The Flash equivalent of Application.application.parameters is stage.loaderInfo.parameters.

This blog explains how you can do this in a consistent manner.

dirkgently
@dirkgently Your solution works wonderfully in a Flex environment, but the Application.app construct doesn't exist in Flash; the result of which is that it doesn't quite solve this problem. Also EI.available simply ensures that you are in a EI enabled container. Thanks for your answer though.
monvural
See my updated answer. Also, do read the links ;)
dirkgently
A: 

It seems pretty well documented that accessing these parameter values is not possible from either Flex or Flash. Flashvars can be accessed as is being suggested by the previous answer, but parameter values of the object tag cannot.

monvural
A: 

There is no way to access the allowScriptAccess value directly, but you can pretty easily determine whether you are able to make an ExternalInterface call simply by using a try-catch.

try
{
  ExternalInterface.call( 'document.getElementById', 'NOELEMENTBYTHISNAME' );
  allowScriptAccess = true;
}
catch( err:SecurityError )
{
  allowScriptAccess = false;
}

You can then use your allowScriptAccess to determine application control flow to avoid making any further ExternalInterface calls.

Travis