Greetings,
This is regarding a Flash security/sandbox issue. I was wondering if there was a way for the loaded Flash .swf object to know whether allowNetworking="internal"
is set for it, possibly using ActionScript (2.0 or 3.0).
I found a solution, but it does not differentiate whether the restrictio开发者_如何学Cns are from allowNetworking
or allowScriptAccess
settings.
I am not particularly looking for a work around (although that would be interesting too), but just to be able to detect whether specifically allowNetworking
is set to "internal"
or at least something other than "all"
.
Cheers :)
You can test for the networking API restrictions by trying to execute specific restricted APIs and seeing if a SecurityError is thrown.
public static function getNetworkingRestriction():String {
var result:String = "all"; // default level
try {
// first try SharedObject. If it throws a SecurityError, then allowNetworking="none"
SharedObject.getLocal("test");
try {
// SharedObject didn't throw a SecurityError.
//If ExternalInterface.call() throws a SecurityError then allowNetworking="internal"
ExternalInterface.call("");
}
catch (e:SecurityError) {
result = "internal";
}
}
catch (e:SecurityError) {
result = "none";
}
return result;
}
A list of the restricted networking APIs can be found here
精彩评论