我正在开发一个加载SWF文件的AIR应用程序。我将加载的SWF文件中的符号添加到FLEX-canvas:
//...
_loader = new Loader();
var urlReq:URLRequest = new URLRequest(_file);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadCompleted);
_loader.load(urlReq);
//...
private function swfLoadCompleted(loadEvent:Event):void
{
var swfApplicationDomain:ApplicationDomain = (loadEvent.target.applicationDomain as ApplicationDomain);
var symbolNames:Vector.<String> = swfApplicationDomain.getQualifiedDefinitionNames();
for each (var symbolName:String in symbolNames)
{
var clazz:Class = swfApplicationDomain.getDefinition(symbolName) as Class;
var symbol:Object = new clazz();
if (symbol is MovieClip)
{
canvas.addChild(symbol);
}
}
}
当我点击符号的一部分时,我会得到错误:
*** Security Sandbox Violation ***
SecurityDomain 'file:///C:/Users/user1/Desktop/Symbol_in_symbol_example.swf' tried to access incompatible context 'app:/MyProgram.swf'
由于这个错误,我不能为这种符号实现拖放。造成这个问题的原因是什么?
答案 0 :(得分:1)
如果要将类从一个swf文件加载到空中应用程序,则必须分两步加载它。