我在 applicationStorageDirectory 中有一个.as
文件,想从 applicationDirectory 实例化该文件。
是否可以从applicationDirectory实例化一类applicationStorageDirectory?
我曾经尝试使用getDefinitionByName()
,但这不起作用。它显示“ ReferenceError: Error #1065: Variable Demo is not defined
”。
此行触发错误:
var demoClass: Class = myTextLoader.contentLoaderInfo.applicationDomain.getDefinition("Demo") as Class;
这是我的代码:
var myTextLoader: Loader = new Loader();
function loadSWF()
{
var targetFile: File = File.applicationStorageDirectory.resolvePath("GeneralButtons.swf");
if (targetFile.exists)
{
myTextLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadComplete2);
myTextLoader.load(new URLRequest(targetFile.url));
}
else
{
trace("Code does not exists");
}
}
function swfLoadComplete2(evt: Event) :void
{
trace("swfLoadComplete2");
var demoClass: Class = myTextLoader.contentLoaderInfo.applicationDomain.getDefinition("Demo") as Class;
var obj = new demoClass();
}