设置swfobject的路径

时间:2011-02-02 05:17:57

标签: swfobject

我在设置swfobject的路径时遇到了麻烦。在我的项目目录结构中,我将swfobject.js和loadmovie.js文件放在“Project / src / main / webapp / resources”目录中。在同一目录中,我放置了test.swf文件。 loadmovie.js的内容是:

var swfVersionStr = "10.0.0";
var xiSwfUrlStr = "playerProductInstall.swf";
var flashvars = {};
var params = {};
params.wmode = "transparent";
params.quality = "high";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "test";
attributes.name = "test";
attributes.align = "left";
swfobject.embedSWF("test.swf", "movieDiv", "202", "380", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
swfobject.createCSS("#flashContent", "display:block;text-align:left;");

但是test.swf没有加载网页。如果我在渲染swfobject之后查看网页的来源正在转换为:

<object type="application/x-shockwave-flash" id="test" name="test" align="left" data="test.swf" width="202" height="380">
   <param name="wmode" value="transparent">
   <param name="quality" value="high">
   <param name="allowscriptaccess" value="sameDomain">
   <param name="allowfullscreen" value="true">
</object>

如果我用data =“http://localhost/project/resources/test.swf”替换data =“test.swf”,那么可以看到swf。请帮忙。我该如何设置路径?谢谢

1 个答案:

答案 0 :(得分:1)

使用绝对路径:

  

数据= “/项目/资源/ test.swf”