AS3:在 for 循环中加载 SWF
我正在尝试在 for 循环中加载外部 SWF,但这个问题确实困扰着我:在事件处理程序中,我需要知道已加载的 SWF 的文件名,但我无法获取该文件名。下面的代码显示了我正在尝试做的事情。
有人有什么想法吗?
function loadManySWFs(arrayOfFileNames:Array)
{
for(var i=0; i<arrayOfFileNames; i++)
{
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest(arrayOfFileNames[i]));
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
mLoader.load(mRequest);
}
}
function onLoadComplete(e:Event)
{
// Here I need to know the filename of the SWF that was loaded. How can I do this?
}
感谢您的帮助!
I'm trying to load external SWFs in a for loop, and I have this problem that is really eating me: In the event handler I need to know the filename of the SWF that was loaded, but I can't obtain this. The code below shows what I'm trying to do.
Does anybody have any idea?
function loadManySWFs(arrayOfFileNames:Array)
{
for(var i=0; i<arrayOfFileNames; i++)
{
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest(arrayOfFileNames[i]));
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
mLoader.load(mRequest);
}
}
function onLoadComplete(e:Event)
{
// Here I need to know the filename of the SWF that was loaded. How can I do this?
}
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
event.target
将包含相关的LoaderInfo
对象,您可以从中检索 url。event.target
would contain the relevantLoaderInfo
object, you can retrieve the url from that.