如何在Flash中使用基本参数
我有一个 flash 文件(flash 的完整链接类似于 http: //localhost:8888/PROJECT/swf/audio/player.swf) 加载 mp3 文件(链接到我通过 flashvars 用 php 发送的 mp3)
我已嵌入动态(使用 swfobject)此 swf 到我的页面。没关系。然后我将 ajax-request 发送到脚本,该脚本使用 flash 重新加载 div。 Div 为空。
通过实验,我发现我在相对路径方面遇到了麻烦。 Flash 文件嵌入地址为 ./swf/audio/player.swf,mp3 地址为 ./media/audio/user/1/random.mp3。 相对于根目录,这些路径是正确的。
但是,如果我用 ../../media/audio/user/1/random.mp3 更改 mp3-address ,一切都会正常工作!
我搜索并发现flash中有'base'参数,它设置flash相对路径的根目录。我尝试像这样使用它: var params = {base:"http://localhost:8888/PROJECT/"};但没有结果。
我该如何解决这个问题?
I have a flash file(full link to flash looks like http://localhost:8888/PROJECT/swf/audio/player.swf) which loads mp3-file(link to mp3 I send with php through flashvars)
I've embed dynamically(with swfobject) this swf to my page. It's ok. Then I send ajax-request to script, which reloading div with flash. Div is empty.
Experimentally I found out that I've trouble with relative paths. Flash file embed with this address ./swf/audio/player.swf and mp3-address is ./media/audio/user/1/random.mp3.
Relative to the root dir those paths are correct.
But if I change mp3-address with ../../media/audio/user/1/random.mp3 everything works as it should!
I've searched and found that there is 'base' param in flash, which set the root dir for flash relative paths. I try use it like this: var params = {base:"http://localhost:8888/PROJECT/"}; but without result.
How do I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
swf 相对路径的起始位置基于基本参数。如果未设置base,它将默认为保存.swf 的html 页面的位置,无论swf 在哪里。
http://localhost:8888/PROJECT/media/audio/user/1 /random.mp3
如果参数设置为 .../PROJECT/,这应该是你媒体的路径,
小心 AS2 中路径前面的点(单个 .),它会失败有时是AS2。尝试在基本路径末尾或相对路径开头使用或不使用斜杠。像这样的简单事情可能会弄乱路径,导致它们不可读。
The swf's starting location for relative paths is based on the base param. If base is not set, it will default to the position of the html page holding the .swf, wherever the swf is.
http://localhost:8888/PROJECT/media/audio/user/1/random.mp3
This should be the path to you mediea if the param is set as .../PROJECT/
Be carefull with dots in front of paths in AS2, (a single .), it will fail in AS2 sometimes. Try with or without slashes at the end of the base path or at the start of the relative path. Simple things like that can mess up the paths so that they are not readable.