当从 CDN 提供服务时,预加载器如何动态确定目标 URL
我有一个从 CDN 提供服务的预加载器,我希望它也从 CDN 加载目标 SWF,但是当它使用 loaderInfo
时,它会返回 html 文件的主机名...如下设置:
- index.html(托管在主域上)使用 SWFObject 嵌入预加载器
- preloader.as 托管在远程 CDN 上,包含
- 要加载的 target.swf
下面的代码我从另一个我无法联系的开发人员那里继承了此代码,并且我不是 AS 编码员...
var url:String = "target.swf";
....
var request:URLRequest = new URLRequest(url);
loader = new Loader();
loader.load(request);
这是我尝试过的,但我认为它返回的是 index.html 的 url,而不是 CDN 托管的预加载器:
var currentUrl:String = stage.loaderInfo.url;
var url:String = currentUrl.substring(0,currentUrl.length-13) + "target.swf";
....
是否有某种方法可以获取预加载器是由哪个 CDN 提供的?
谢谢, 乔纳森
I have a preloader that is being served from a CDN, and I want it to load the target SWF also from the CDN but when it uses loaderInfo
, it returns the hostname of the html file... Here's the setup:
- index.html (hosted on primary domain) uses SWFObject to embed preloader
- preloader.as hosted on remote CDN, contains code below
- target.swf is to be loaded
I have inherited this code from another developer that I can't contact and I'm not an AS coder...
var url:String = "target.swf";
....
var request:URLRequest = new URLRequest(url);
loader = new Loader();
loader.load(request);
This is what I've tried, but I think it's returning the url of the index.html, not the CDN-hosted preloader:
var currentUrl:String = stage.loaderInfo.url;
var url:String = currentUrl.substring(0,currentUrl.length-13) + "target.swf";
....
Is there some way that I can get the URL that the preloader was served from which is the CDN?
Thanks,
Jonathan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
stage.loaderInfo.url
实际上返回显示 swf 的页面的 URL。您可以将 CDN 的地址作为参数提供给您的 swf:HTML
然后要检索此参数,请使用:
AS3
stage.loaderInfo.url
returns indeed the URL of the page displaying the swf. You may give your swf the address of the CDN as a parameter:HTML
Then to retrieve this parameter, use:
AS3