I have a project written in ActionScript 3 using Adobe Flash Builder 4.5. It registers several functions in an ExternalInterface
, so that they may be called from JavaScript.
If I access the Flash document on a server, for example http://localhost/
, I am able to call the defined functions successfully. If I just open the file in my browser directly (through the file:///
protocol) it will fail with an error like this:
*** Security Sandbox Violation ***
SecurityDomain 'null' tried to access incompatible context 'file:///Users/foo/src/bar/baz/bin-debug/app.swf'
A reasonable security restriction, but it has a paradoxical consequence: I'm unable to debug the use of ExternalInterface
because the Flash Builder debugger opens the document through file:
.
It seems too absurd to be true that such an important feature can't be debugged normally.
How can I use the debugger with ExternalInterface
?
There are two ways to solve this:
- By setting the
use-network=false
compiler flag (see: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7a92.html ctrl-f use-network) - Configuring the Flash Builder debugger to launch the HTTP URL when debugging. To do that, click: Run -> Debug Configurations, then under "URL or path to launch", enter (say) "http://localhost/"
I generally prefer the latter.
来源:https://stackoverflow.com/questions/13034375/is-it-possible-to-debug-externalinterface-through-file-from-flash-builder