Flex Loading external swf prevents other functions
I am able to use the Loader class to import an external swf into my project, its working great. But Im also trying to do a ImageSnapshot of the stage which works fine before the external swf is imported. After the swf is imported the ImageSnapshot no longer works.
Any idea? is there a event that the external swf is bringing wit开发者_Python百科h it that would disable it?
Try to send a LoaderContext
object within the Loader.load()
function. On that LoaderContext
, set checkPolicyFile
to true. Like this:
var loader:Loader = new Loader();
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.checkPolicyFile = true;
loader.load(new URLRequest("your swf url"), loaderContext);
What the checkPolicyFile
flag does is that it tells the host swf to load a policy file from the loaded swf's server. If you haven't specified that flag at loading time you will recieve a SecurityError
when you try to get pixel data from the loaded swf through BitmapData.draw()
.
Adobe docs on the subject: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/LoaderContext.html#checkPolicyFile
精彩评论